コード例 #1
0
        public async Task <ActionResult <SubService> > Edit(string id, SubService value)
        {
            value.Id      = ObjectId.Parse(id);
            value.Service = await _service.GetById(value.ServiceId.ToString());

            _SubService.Update(value, id);

            await _uow.Commit();

            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public IActionResult SaveEntity(SubViewModel vm)
 {
     if (!ModelState.IsValid)
     {
         IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
         return(new BadRequestObjectResult(allErrors));
     }
     else
     {
         int id = 0;
         if (vm.Id == 0)
         {
             id = _subService.Add(vm);
         }
         else
         {
             _subService.Update(vm);
             id = vm.Id;
         }
         return(new OkObjectResult(id));
     }
 }