Ejemplo n.º 1
0
        public IActionResult Edit(TaskListCreateViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (ConfigurationManager.AppSettings.IsTrialVersion)
            {
                response.SetIsTrial();
                return(Ok(response));
            }
            using (_dbContext)
            {
                /*if (_dbContext.DncTaskList.Count(x => x.Name == model.Name && x.Code != model.Code) > 0)
                 * {
                 *  response.SetFailed("角色已存在");
                 *  return Ok(response);
                 * }*/
                //FirstOrDefault返回序列中的第一个元素;如果序列中不包含任何元素,则返回默认值
                var entity = _dbContext.DncTaskList.FirstOrDefault(x => x.Code == model.Code);

                entity.KeyWork                = model.KeyWork;
                entity.ImportanceOfWork       = model.ImportanceOfWork;
                entity.CreationTime           = DateTime.Now;
                entity.MajorIinitiatives      = model.MajorIinitiatives;
                entity.ImplementationProgress = model.ImplementationProgress;
                entity.ProgressStatus         = model.ProgressStatus;
                entity.PersonLiable           = model.PersonLiable;
                entity.Remarks                = model.Remarks;
                entity.IsComplete             = model.IsComplete;
                _dbContext.SaveChanges();
                return(Ok(response));
            }
        }
Ejemplo n.º 2
0
        public IActionResult Create(TaskListCreateViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            using (_dbContext)
            {
                var entity = _mapper.Map <TaskListCreateViewModel, DncTaskList>(model);
                entity.KeyWork                = model.KeyWork;
                entity.ImportanceOfWork       = model.ImportanceOfWork;
                entity.CreationTime           = DateTime.Now;
                entity.MajorIinitiatives      = model.MajorIinitiatives;
                entity.ImplementationProgress = model.ImplementationProgress;
                entity.ProgressStatus         = model.ProgressStatus;
                entity.PersonLiable           = model.PersonLiable;
                entity.Remarks                = model.Remarks;
                entity.IsComplete             = model.IsComplete;
                entity.Code = RandomHelper.GetRandomizer(8, true, false, true, true);
                _dbContext.DncTaskList.Add(entity);
                _dbContext.SaveChanges();

                response.SetSuccess();
                return(Ok(response));
            }
        }