public IActionResult CreateYachtTours([FromBody] YachtTourOperationDetailCreateModel model) { var baseresponse = _yachtTourOperationDetailService.Create(model); if (baseresponse.IsSuccessStatusCode) { return(Ok(baseresponse)); } return(BadRequest()); }
private YachtTourOperationDetails GenerateForCreate(YachtTourOperationDetailCreateModel model) { var now = DateTime.Now.Date; var userId = UserContextHelper.UserId; var entity = _mapper.Map <YachtTourOperationDetailCreateModel, YachtTourOperationDetails>(model); entity.Deleted = false; entity.IsActive = true; entity.LastModifiedBy = userId; entity.LastModifiedDate = now; return(entity); }
public BaseResponse <bool> Create(YachtTourOperationDetailCreateModel model) { try { var entity = GenerateForCreate(model); if (entity == null) { return(BaseResponse <bool> .BadRequest()); } _db.YachtTourOperationDetails.Add(entity); var result = _db.SaveChanges(); return(result > 0 ? BaseResponse <bool> .Success(true) : BaseResponse <bool> .BadRequest()); } catch (Exception ex) { return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace)); } }