Beispiel #1
0
        public async Task <IActionResult> Create(agentModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Operation(false, "数据验证失败"));
            }
            Agent module = MapperHelper.Map <agentModel, Agent>(model);

            module.Id = module.CreateId();

            var r = await _agentApp.CreateAsync(module, CurrentUser);

            return(Operation(r.IsSuc, r.IsSuc ? "数据添加成功" : r.Msg));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(agentModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Operation(false, GetErrorFromModelStateStr()));
            }

            Agent m = await _agentApp.GetAsync(model.Id);

            if (m == null)
            {
                return(Operation(false, "数据不存在或已被删除"));
            }

            m = MapperHelper.Map <agentModel, Agent>(model, m);
            var r = await _agentApp.UpdateAsync(m, CurrentUser);

            return(Operation(r.IsSuc, r.Msg));
        }
Beispiel #3
0
 /// <summary>
 /// Возвращает экземпляр модели (контекста)
 /// </summary>
 /// <returns>Модель</returns>
 public static agentModel getDbContext()
 {
     dbContext = dbContext ?? new agentModel();
     return(dbContext);
 }