public Stewadress MapStewadress(StewadressDto value) { return(new Stewadress { Id = value.ID, Name = value.FirstName, LastName = value.LastName, Birthday = value.Birthday }); }
public IActionResult Delete([FromBody] StewadressDto stewadress) { try { service.Delete(stewadress); return(NoContent()); } catch (Exception) { return(NotFound()); } }
public void Create(StewadressDto Stewadress) { var validationResult = validator.Validate(Stewadress); if (validationResult.IsValid) { unit.Stewadresses.Create(mapper.MapStewadress(Stewadress)); } else { throw new ValidationException(validationResult.Errors); } }
public IActionResult Post([FromBody] StewadressDto value) { try { service.Create(value); return(Ok()); } catch (ValidationException e) { return(BadRequest(e.Message)); } catch (Exception) { return(BadRequest()); } }
public IActionResult Put(int id, [FromBody] StewadressDto stewadress) { try { service.Update(stewadress, id); return(Ok()); } catch (NotFoundException) { return(NotFound()); } catch (ValidationException e) { return(BadRequest(e.Message)); } catch (Exception) { return(BadRequest()); } }
public void Update(StewadressDto Stewadress, int id) { var validationResult = validator.Validate(Stewadress); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } try { unit.Stewadresses.Update(mapper.MapStewadress(Stewadress), id); } catch (ArgumentNullException) { throw new NotFoundException(); } catch (Exception) { throw; } }
public void Delete(StewadressDto Stewadress) { unit.Stewadresses.Delete(mapper.MapStewadress(Stewadress)); }