public BaseViewModel <LocationViewModel> UpdateLocation(UpdateLocationRequestViewModel location) { var entity = _repository.GetById(location.Id); if (entity == null || entity.IsDelete) { return(new BaseViewModel <LocationViewModel> { StatusCode = HttpStatusCode.NotFound, Description = MessageHandler.CustomErrMessage(ErrMessageConstants.NOTFOUND), Code = ErrMessageConstants.NOTFOUND }); } entity = _mapper.Map(location, entity); entity.SetDefaultUpdateValue(_repository.GetUsername()); _repository.Update(entity); var result = new BaseViewModel <LocationViewModel> { Data = _mapper.Map <LocationViewModel>(entity), }; Save(); return(result); }
public ActionResult <BaseViewModel <LocationViewModel> > PutLocation([CheckGuid(Property = "LocationId")] string id, [FromBody] UpdateLocationRequestViewModel location) { var guidId = new Guid(id); location.Id = guidId; var result = _locationService.UpdateLocation(location); this.HttpContext.Response.StatusCode = (int)result.StatusCode; return(result); }