Beispiel #1
0
        public IActionResult Create(MorningCheckViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (AuthContextService.CurrentUser.SchoolGuid == null)
            {
                response.SetFailed("请登录学校账号");
                return(Ok(response));
            }
            using (_dbITMContext)
            {
                var org = _dbITMContext.Orgs.FirstOrDefault(x => x.SchoolName == AuthContextService.CurrentUser.SchoolName);
                if (org != null)
                {
                    var entity = new Inspections();
                    entity.InspectionId     = 0;
                    entity.OrganizationId   = org.OrganizationId;
                    entity.OrganizationName = org.Name;
                    entity.ShouldCount      = model.ShouldCount.ToString();
                    entity.ActualCount      = "0";
                    entity.UnqualifiedCount = "0";
                    entity.CreatedUser      = 0;
                    entity.Inspector        = model.Inspector;
                    entity.CreatedDate      = DateTime.Now;
                    entity.CreatedAt        = DateTime.Now;
                    entity.IsSupply         = true;
                    entity.Type             = 2;
                    entity.Sync             = 0;
                    entity.IsDifferent      = true;
                    entity.DepartmentId     = model.DepartmentId;
                    //暂无班组选择
                    entity.TeamGroupId = 0;
                    _dbITMContext.Inspections.Add(entity);
                    _dbITMContext.SaveChanges();
                    response.SetSuccess("添加成功");
                }
                else
                {
                    response.SetFailed("不存在该组织");
                }


                return(Ok(response));
            }
        }
Beispiel #2
0
        public IActionResult Edit(MorningCheckViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (AuthContextService.CurrentUser.SchoolGuid == null)
            {
                response.SetFailed("请登录学校账号");
                return(Ok(response));
            }
            using (_dbITMContext)
            {
                var entity = _dbITMContext.Inspections.FirstOrDefault(x => x.Id == model.Id);
                entity.ShouldCount = model.ShouldCount.ToString();
                //entity.ActualCount = model.ActualCount;
                //entity.UnqualifiedCount = (model.ShouldCount- model.ActualCount).ToString();
                entity.Inspector    = model.Inspector;
                entity.DepartmentId = model.DepartmentId;
                _dbITMContext.SaveChanges();
                response.SetSuccess("修改成功");
                return(Ok(response));
            }
        }