username@email.com
2024-07-09 38f88a13e2d7ba9dc80126245339505aab2e9fd5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using AutoMapper;
using DTO;
using IServices;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using zhengcaioa.Models;
 
 
namespace Services
{
    public class CusFangwenjiluService : ICusFangwenjiluService
    {
 
        private readonly zhengcaioaContext _context;
        private readonly IMapper _mapper;
        public CusFangwenjiluService(zhengcaioaContext context, IMapper mapper)
        {
            _context = context;
            _mapper = mapper;
        }
 
        public ResultEntity save(CusFangwenjiluDTO dto)
        {
            ResultEntity resultEntity = new ResultEntity();
            try
            {
                var model = _mapper.Map<CusFangwenjilu>(dto);
                if (String.IsNullOrEmpty(model.Id))
                {
                    model.Id = Guid.NewGuid().ToString();
 
 
                    _context.CusFangwenjilus.Add(model);
                }
                else
                {
                    var updatepltRole = _context.CusFangwenjilus.Find(model.Id);
                    updatepltRole.Fasongfangshi = model.Fasongfangshi;
                    updatepltRole.Fasongneirong = model.Fasongneirong;
                    updatepltRole.Jieshouren = model.Jieshouren;
                  
 
                    updatepltRole.RecStatus = model.RecStatus;
                    // updatepltRole.Creater = pltRole.Creater;
                    //updatepltRole.Createtime = pltRole.Createtime;
                    updatepltRole.Modifier = model.Modifier;
                    updatepltRole.Modifytime = model.Modifytime;
 
                }
 
                _context.SaveChanges();
                resultEntity.ReturnID = model.Id;
                resultEntity.Result = true;
            }
            catch (Exception ex)
            {
                resultEntity.Result = false;
                resultEntity.Message = "保存失败,请联系管理员";
 
            }
            return resultEntity;
        }
 
        public CusFangwenjiluDTO Get(string id)
        {
            var entity = _context.CusFangwenjilus.Find(id);
 
            if (entity.RecStatus != "A")
            {
                entity = new CusFangwenjilu();
            }
            var CusFangwenjiluDTO = _mapper.Map<CusFangwenjiluDTO>(entity);
            return CusFangwenjiluDTO;
        }
 
        
 
        public ResultEntity ModifyStatus(string id, string userid)
        {
 
            ResultEntity result = new ResultEntity();
            result.Result = true;
 
            var model = _context.CusFangwenjilus.Find(id);
            if (model != null)
            {
                model.RecStatus = "D";
                model.Modifier = userid;
                model.Modifytime = DateTime.Now;
                _context.SaveChanges();
            }
 
            return result;
        }
 
 
        /// <summary>
        /// 获取所有有效角色
        /// </summary>
        /// <returns></returns>
        public List<CusFangwenjiluDTO> GetList()
        {
 
 
            var listPosition = _context.CusFangwenjilus.Where(r => r.RecStatus == "A").ToList();
 
            var list = _mapper.Map<List<CusFangwenjiluDTO>>(listPosition);
            return list;
        }
 
 
 
        /// <summary>
        /// 获取所有有效角色
        /// </summary>
        /// <returns></returns>
        public List<CusFangwenjiluDTO> GetListsalary(string userid, DateTime datemin, DateTime datemax)
        {
 
 
            var listPosition = _context.CusFangwenjilus.Where(r => r.RecStatus == "A" && r.Creater == userid && r.Createtime >= datemin && r.Createtime < datemax).ToList();
 
            var list = _mapper.Map<List<CusFangwenjiluDTO>>(listPosition);
            return list;
        }
 
    }
}