/// <summary> /// GET METHOD FOR VALUABLE ITEM DETAILS /// </summary> /// <param name="id"></param> /// <returns></returns> #region GET METHOD FOR VALUABLE ITEM DETAILS // GET: api/ValuableItemDetails/5 public ValuableItemDetailsRef Get(int id) { ValuableItemDetailsRef valuableItemDetailsRef = new ValuableItemDetailsRef(); try { ValuableItemsDetailsClass valuableItemClass = new ValuableItemsDetailsClass(); if (id > 0) { valuableItemDetailsRef = valuableItemClass.GetValuablesItemDetails(id); } else { valuableItemDetailsRef.Status = "Failure"; valuableItemDetailsRef.ErrorMessage.Add("No Data available.."); } } catch (Exception xp) { valuableItemDetailsRef.Status = "Failure"; valuableItemDetailsRef.ErrorMessage.Add(xp.Message); } finally { } return(valuableItemDetailsRef); }
public ValuableItemDetailsRef GetValuablesItemDetails(int Id) { ValuableItemDetailsRef valuableItemRef = new ValuableItemDetailsRef(); try { ValuableItemDetails valuableItemModel = new ValuableItemDetails(); MasterDataEntities db = new MasterDataEntities(); var str = db.IT_CC_GET_ValuablesItemDetails(Id).ToList(); if (str.Count > 0) { foreach (var item in str) { valuableItemModel = new ValuableItemDetails(); valuableItemModel.ValuablesSumInsured = item.ValuablesSumInsured; valuableItemModel.ValuablesDescription = item.ValuablesDescription; valuableItemRef.ValuableItemDetailsData = valuableItemModel; valuableItemRef.Status = "Success"; } } else { valuableItemRef.ErrorMessage.Add("No Data Available"); valuableItemRef.Status = "Failure"; } } catch (Exception xp) { valuableItemRef.ErrorMessage.Add(xp.Message); valuableItemRef.Status = "Failure"; } finally { } return(valuableItemRef); }
// POST: api/ValuableItemDetails public ValuableItemDetailsRef Post([FromBody] ValuableItemDetails value) { ValuableItemDetailsRef valuableItemDetailsRef = new ValuableItemDetailsRef(); ValuableItemsDetailsClass valuableItemClass = new ValuableItemsDetailsClass(); try { List <string> Errors = new List <string>(); valuableItemDetailsRef.ErrorMessage = new List <string>(); if (value.PcId == null || value.PcId <= 0) { Errors.Add("PolicyID is required"); } if (value.TrId == null || value.TrId <= 0) { Errors.Add("TransactionID is required"); } if (value.HomeID == null || value.HomeID <= 0) { Errors.Add("HomeID is required"); } if (string.IsNullOrWhiteSpace(value.ValuablesDescription)) { Errors.Add("Description is required"); } if (value.ValuablesSumInsured == null || value.ValuablesSumInsured <= 0) { Errors.Add("SumInsured is required"); } if (value.ValuablesItemID == null || value.ValuablesItemID <= 0) { Errors.Add("ValuableItemID is required"); } if (Errors != null && Errors.Count() > 0) { valuableItemDetailsRef.Status = "Failure"; valuableItemDetailsRef.ErrorMessage = Errors; return(valuableItemDetailsRef); } else { int?result = valuableItemClass.InsertValuablesItemDetails(value); if (result.HasValue && result > 0) { valuableItemDetailsRef.Status = "Success"; valuableItemDetailsRef.ValuableItemDetailsData.ValuablesItemID = result.Value; } else if (result.HasValue && result == (int)ValuableResult.Exception) { valuableItemDetailsRef.Status = "Failure"; valuableItemDetailsRef.ErrorMessage.Add("Failed to insert."); } } } catch (Exception xp) { valuableItemDetailsRef.Status = "Failure"; valuableItemDetailsRef.ErrorMessage.Add(xp.Message); } finally { } return(valuableItemDetailsRef); }