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