public async Task <IActionResult> Create([FromBody] CreateHobbyViewModel vm) { var result = await _services.CreateAsync(_mapper.Map <DirectoryDTO>(vm)); if (result.IsValid) { await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Hobby); return(CreatedAtRoute("GetHobby", new { version = "1.0", controller = "Hobby", id = result.Result }, vm)); } return(UnprocessableEntity(result.ErrorsList)); }
public async Task <IActionResult> Create(HobbyViewModel vm) { if (ModelState.IsValid) { var result = await _services.CreateAsync(_mapper.Map <DirectoryDTO>(vm)); return(result.IsValid ? RedirectToAction("Index") : _oops.OutPutError("Hobby", "Index", result.ErrorsList)); } return(View(vm)); }
public async Task <IActionResult> Create(CreateHobbyViewModel vm) { if (ModelState.IsValid) { var result = await _services.CreateAsync(_mapper.Map <DirectoryDTO>(vm)); if (result.IsValid) { await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Hobby); return(RedirectToAction("Index")); } TempData["ErrorsList"] = result.ErrorsList; } return(View(vm)); }
public async Task <IActionResult> Create([FromBody] CreateHobbyViewModel vm) { if (ModelState.IsValid) { var result = await _services.CreateAsync(_mapper.Map <DirectoryDTO>(vm)); if (result.IsValid) { await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Hobby); return(Ok(result)); } return(BadRequest(result)); } return(BadRequest()); }