public SowDetailModel GetSowPlannedDetailsById(int sowdetailId) { var sowDetail = _OperationalPortalEntities.SowDetails.FirstOrDefault(x => x.SowDetailID == sowdetailId); SowDetailModel sowDetailObj = Mapper.Map <SowDetail, SowDetailModel>(sowDetail); return(sowDetailObj); }
public string SaveSowPlannedDetails(SowDetailModel sowDetailModel) { string result = string.Empty; try { SowDetail sowDetail = _OperationalPortalEntities.SowDetails.FirstOrDefault(x => x.SowDetailID == sowDetailModel.SowDetailID); if (sowDetail != null) { Mapper.Map(sowDetailModel, sowDetail); result = "SowDetails Updated Successfully"; } else { sowDetail = new SowDetail(); Mapper.Map(sowDetailModel, sowDetail); _OperationalPortalEntities.SowDetails.Add(sowDetail); result = "SowDetails Saved Successfully"; } _OperationalPortalEntities.SaveChanges(); } catch (Exception ex) { result = ex.Message.ToString(); } return(result); }
public IHttpActionResult SaveSowHeader([FromBody] SowDetailModel sowDetailModel) { var sowdetails = _sowplannedInfo.SaveSowPlannedDetails(sowDetailModel); if (sowdetails == null) { return(NotFound()); } return(Ok(sowdetails)); }