public async Task <IActionResult> Put([FromBody] ProtectionAreaViewModel protectionArea) { try { await _appService.Update(protectionArea); return(Response(protectionArea)); } catch (Exception) { // TODO: log error return(BadRequest(new { success = false, errors = new string[] { "Protection area not updated" } })); } }
public async Task <IActionResult> Post([FromBody] ProtectionAreaViewModel protectionArea) { try { if (!ModelState.IsValid) { NotifyModelStateErrors(); return(Response(protectionArea)); } await _appService.Add(protectionArea);; return(Response(protectionArea)); } catch (Exception) { // TODO: log error return(BadRequest(new { success = false, errors = new string[] { "Protection area not inserted" } })); } }
public async Task Update(ProtectionAreaViewModel protectionArea) { var updateCommand = _mapper.Map <UpdateProtectionAreaCommand>(protectionArea); await _bus.SendCommand(updateCommand); }
public async Task Add(ProtectionAreaViewModel protectionArea) { var registerCommand = _mapper.Map <RegisterProtectionAreaCommand>(protectionArea); await _bus.SendCommand(registerCommand); }