コード例 #1
0
        public async Task <ReturnData <bool> > EditAsync(int id, EditProductDto model)
        {
            var result = new ReturnData <bool>();
            var check  = await _context.Products.FirstOrDefaultAsync(i => i.Number == model.Number);

            if (check != null)
            {
                result.Message = "存在相同编码,修改失败";
                result.Result  = false;
                return(result);
            }
            var products = await _context.Products.FirstOrDefaultAsync(i => i.Id == id);

            if (products != null)
            {
                var checktime = await CheckTimeOut.Check(products.LastUpTime, model.LastUpTime);

                if (!checktime.Success)
                {
                    return(checktime);
                }
                products.Name       = model.Name;
                products.LastUpTime = DateTime.Now;
                products.Price      = model.Price;
                products.Number     = model.Number;
            }
            result.Result = await _context.SaveChangesAsync() > 0;

            return(result);
        }
コード例 #2
0
        public async Task <ReturnData <bool> > EditAsync(int id, EditPositionDto model)
        {
            var result = new ReturnData <bool>();
            var check  = await _context.Positions.FirstOrDefaultAsync(i => i.DepartmentId == model.DepartmentId && i.Name == model.Name && i.Id != id);

            if (check != null)
            {
                result.Message = "同一部门存在相同职位,修改失败";
                result.Result  = false;
                return(result);
            }
            var position = await _context.Positions.FirstOrDefaultAsync(i => i.Id == id);

            if (position != null)
            {
                var checktime = await CheckTimeOut.Check(position.LastUpTime, model.LastUpTime);

                if (!checktime.Success)
                {
                    return(checktime);
                }
                position.Name         = model.Name;
                position.DepartmentId = model.DepartmentId;
            }
            result.Result = await _context.SaveChangesAsync() > 0;

            return(result);
        }
コード例 #3
0
        public async Task <ReturnData <bool> > EditAsync(int id, EditStaffinfoDto model)
        {
            var result = new ReturnData <bool>();
            var check  = await _context.StaffInfos.FirstOrDefaultAsync(i => i.Name == model.Name && i.Email == model.Email && i.Id != id);

            if (check != null)
            {
                result.Message = "存在相同员工,修改失败";
                result.Result  = false;
                return(result);
            }
            var staffInfos = await _context.StaffInfos.FirstOrDefaultAsync(i => i.Id == id);

            if (staffInfos != null)
            {
                var checktime = await CheckTimeOut.Check(staffInfos.LastUpTime, model.LastUpTime);

                if (!checktime.Success)
                {
                    return(checktime);
                }
                staffInfos.Email      = model.Email;
                staffInfos.Name       = model.Name;
                staffInfos.EntryTime  = model.EntryTime;
                staffInfos.LastUpTime = DateTime.Now;
                staffInfos.Phone      = model.Phone;
                staffInfos.PositionId = model.PositionId;
                if (model.WorkingStatus == Model.Enums.WorkingStatus.Quit)
                {
                    staffInfos.ResignationTime = DateTime.Now;
                }
                staffInfos.WorkingStatus = model.WorkingStatus;
            }
            result.Result = await _context.SaveChangesAsync() > 0;

            return(result);
        }