public async Task <IActionResult> Create([FromBody] CreateTourViewModel vm) { var result = await _services.CreateAsync(_mapper.Map <TourDTO>(vm)); if (result.IsValid) { await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Event); return(CreatedAtRoute("GetTour", new { version = "1.0", controller = "Tour", id = result.Result }, vm)); } return(UnprocessableEntity(result.ErrorsList)); }
public async Task <IActionResult> Create(CreateTourViewModel vm) { if (ModelState.IsValid) { var result = await _services.CreateAsync(_mapper.Map <TourDTO>(vm)); if (result.IsValid) { await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Event); return(RedirectToAction("Index")); } TempData["ErrorsList"] = result.ErrorsList; } return(View(vm)); }
public async Task <IActionResult> Create([FromBody] CreateTourViewModel vm) { if (ModelState.IsValid) { var result = await _services.CreateAsync(_mapper.Map <TourDTO>(vm)); if (result.IsValid) { await _systemAuditService.AuditAsync(User.GetEmail(), _accessor.GetIp(), Operations.Insert, Tables.Event); return(Ok(result)); } return(BadRequest(result)); } return(BadRequest()); }