public int UpdateValuablesDetails(int ID, ValuableDetails valuableDetailsModel)
        {
            int icount = 0;

            try
            {
                MasterDataEntities db = new MasterDataEntities();
                icount = db.IT_CC_UPDATE_ValuablesDetails(ID, valuableDetailsModel.ValuablesUnspecifiedSumInsured, valuableDetailsModel.ValuablesExcess);
            }
            catch (Exception xp)
            {
            }
            finally
            {
            }
            return(icount);
        }
        public int InsertValuablesDetails(ValuableDetails valuableDetailsModel)
        {
            int details = 0;

            try
            {
                MasterDataEntities db = new MasterDataEntities();
                details = db.IT_CC_Insert_ValuablesDetails(valuableDetailsModel.PcId, valuableDetailsModel.TrId, valuableDetailsModel.HomeID, valuableDetailsModel.ValuablesUnspecifiedSumInsured, valuableDetailsModel.ValuablesExcess, valuableDetailsModel.PremiumId);
            }
            catch (Exception xp)
            {
            }
            finally
            {
            }
            return(details);
        }
        /// <summary>
        /// GET METHOD FOR VALUABLEDETAILS
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        ///

        #region GET METHOD FOR VALUABLEDETAILS
        public ValuableDetailsRef GetValuablesDetails(int Id)
        {
            ValuableDetailsRef valuableDetailRef = new ValuableDetailsRef();

            try
            {
                ValuableDetails    valuableDetailsModel = new ValuableDetails();
                MasterDataEntities db = new MasterDataEntities();
                var str = db.IT_CC_GET_ValuablesDetails(Id).ToList();
                if (str.Count > 0)
                {
                    foreach (var item in str)
                    {
                        valuableDetailsModel = new ValuableDetails();
                        valuableDetailsModel.ValuablesUnspecifiedSumInsured = item.ValuablesUnspecifiedSumInsured;
                        valuableDetailsModel.ValuablesExcess  = item.ValuablesExcess;
                        valuableDetailRef.ValuableDetailsData = valuableDetailsModel;
                        valuableDetailRef.Status = "Success";
                    }
                }
                else
                {
                    valuableDetailRef.ErrorMessage.Add("No Data Available");
                    valuableDetailRef.Status = "Failure";
                }
            }
            catch (Exception xp)
            {
                valuableDetailRef.ErrorMessage.Add(xp.Message);
                valuableDetailRef.Status = "Failure";
            }
            finally
            {
            }
            return(valuableDetailRef);
        }
Пример #4
0
        // PUT: api/ValuableDetails/5
        public ValuableDetailsRef Put(int id, [FromBody] ValuableDetails value)
        {
            ValuableDetailsRef   valuableDetailsRef = new ValuableDetailsRef();
            ValuableDetailsClass valuableClass      = new ValuableDetailsClass();

            try
            {
                List <string> Errors = new List <string>();
                valuableDetailsRef.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 (value.PremiumId == null || value.PremiumId <= 0)
                {
                    Errors.Add("PremiumID is required");
                }
                if (value.ValuablesDetailID == null || value.ValuablesDetailID <= 0)
                {
                    Errors.Add("ValuableID is required");
                }
                if (value.ValuablesUnspecifiedSumInsured == null || value.ValuablesUnspecifiedSumInsured <= 0)
                {
                    Errors.Add("UnspecifiedsumInsured is required");
                }
                if (value.ValuablesExcess == null || value.ValuablesExcess <= 0)
                {
                    Errors.Add("Excess is required");
                }
                if (Errors != null && Errors.Count() > 0)
                {
                    valuableDetailsRef.Status       = "Failure";
                    valuableDetailsRef.ErrorMessage = Errors;
                    return(valuableDetailsRef);
                }
                else
                {
                    int?result = valuableClass.UpdateValuablesDetails(id, value);
                    if (result.HasValue && result > 0)
                    {
                        valuableDetailsRef.Status = "Success";
                        valuableDetailsRef.ValuableDetailsData.ValuablesDetailID = result.Value;
                    }
                    else if (result.HasValue && result == (int)ValuableResult.Exception)
                    {
                        valuableDetailsRef.Status = "Failure";
                        valuableDetailsRef.ErrorMessage.Add("Failed to insert.");
                    }
                }
            }
            catch (Exception xp)
            {
                valuableDetailsRef.Status = "Failure";
                valuableDetailsRef.ErrorMessage.Add(xp.Message);
            }
            finally
            {
            }
            return(valuableDetailsRef);
        }