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 string DeleteSowPlannedDetail(int sowdetailId) { string result = string.Empty; try { SowDetail sow = _OperationalPortalEntities.SowDetails.FirstOrDefault(x => x.SowDetailID == sowdetailId); if (sow != null) { _OperationalPortalEntities.SowDetails.Remove(sow); _OperationalPortalEntities.SaveChanges(); result = "SowDetails Removed Successfully"; } else { result = "SowDetail Does not exist"; } } catch (Exception ex) { result = ex.Message.ToString(); } return(result); }