Ejemplo n.º 1
0
        //Get Single Record
        public static etblPropertyCancellationPolicyMap GetSingleRecordById(int id)
        {
            etblPropertyCancellationPolicyMap eobj = new etblPropertyCancellationPolicyMap();

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                var dbobj = db.tblPropertyCancellationPolicyMaps.SingleOrDefault(u => u.iCancellationPolicyId == id);
                if (dbobj != null)
                {
                    eobj = (etblPropertyCancellationPolicyMap)OneFineRateAppUtil.clsUtils.ConvertToObject(dbobj, eobj);
                }
            }
            return(eobj);
        }
        public ActionResult Edit(int Id)
        {
            ViewBag.HeaderText = "Modify Policy";
            obj      = BL_tblPropertyCancellationPolicyMap.GetSingleRecordById(Id);
            obj.Mode = "Edit";
            if (obj.dtValidFrom != null)
            {
                obj.validfrom = String.Format("{0:dd/MM/yyyy}", obj.dtValidFrom);
            }
            if (obj.dtValidTo != null)
            {
                obj.validTo = String.Format("{0:dd/MM/yyyy}", obj.dtValidTo);
            }

            return(PartialView("CancellationPolicy", obj));
        }
Ejemplo n.º 3
0
        //Add new record
        public static int AddRecord(etblPropertyCancellationPolicyMap eobj)
        {
            int retval = 0;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    OneFineRate.tblPropertyCancellationPolicyMap dbuser = (OneFineRate.tblPropertyCancellationPolicyMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyCancellationPolicyMap());
                    db.tblPropertyCancellationPolicyMaps.Add(dbuser);
                    db.SaveChanges();
                    retval = 1;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retval);
        }
Ejemplo n.º 4
0
        //Update a record
        public static int UpdateRecord(etblPropertyCancellationPolicyMap eobj)
        {
            int retval = 0;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    OneFineRate.tblPropertyCancellationPolicyMap obj = (OneFineRate.tblPropertyCancellationPolicyMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyCancellationPolicyMap());
                    db.tblPropertyCancellationPolicyMaps.Attach(obj);
                    db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    retval = 1;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retval);
        }
        public string UpdateStatus(int Id, bool Mode)
        {
            object result    = null;
            string strReturn = string.Empty;

            try
            {
                obj = BL_tblPropertyCancellationPolicyMap.GetSingleRecordById(Id);
                if (Mode == true)
                {
                    obj.cStatus = "A";
                }
                else
                {
                    obj.cStatus = "I";
                    string s = BL_tblPropertyCancellationPolicyMap.CheckPolicyMapping(Id);
                    if (s != "")
                    {
                        result    = new { st = 0, msg = s };
                        strReturn = OneFineRateAppUtil.clsUtils.ConvertToJson(result);
                        return(strReturn);
                    }
                }
                int i = BL_tblPropertyCancellationPolicyMap.UpdateRecord(obj);
                if (i == 1)
                {
                    result = new { st = 1, msg = "Updated successfully." };
                }
                else
                {
                    result = new { st = 0, msg = "Kindly try after some time." };
                }
            }
            catch (Exception)
            {
                result = new { st = 0, msg = "Kindly try after some time." };
            }
            strReturn = OneFineRateAppUtil.clsUtils.ConvertToJson(result);
            return(strReturn);
        }
        public ActionResult AddUpdate(etblPropertyCancellationPolicyMap eObj)
        {
            object result = null;

            try
            {
                if (ModelState.IsValid)
                {
                    eObj.dtValidFrom = Convert.ToDateTime(eObj.validfrom);
                    eObj.dtValidTo   = Convert.ToDateTime(eObj.validTo);

                    if (eObj.bIsNonRefundable == false)
                    {
                        if (eObj.dValue.Value < 0)
                        {
                            result = new { st = 0, msg = "Charge cannot be negative." };
                            return(Json(result, JsonRequestBehavior.AllowGet));
                        }
                        if (eObj.dValue.Value > 100)
                        {
                            result = new { st = 0, msg = "Charge cannot be more than 100." };
                            return(Json(result, JsonRequestBehavior.AllowGet));
                        }
                        if (eObj.dHrsDays.Value < 0)
                        {
                            result = new { st = 0, msg = "Cancellation duration cannot be negative." };
                            return(Json(result, JsonRequestBehavior.AllowGet));
                        }
                        if (eObj.dValue.Value > 100)
                        {
                            result = new { st = 0, msg = "Cancellation duration cannot be more than 100." };
                            return(Json(result, JsonRequestBehavior.AllowGet));
                        }
                        string charrgetype = eObj.bIsPercent == true ? "%" : "Nights";
                        string arrival     = eObj.cHrsDays == "Hrs" ? "Hours" : "Days";
                        eObj.sPolicyName = eObj.dValue.Value.ToString().Replace(".00", "") + "" + charrgetype + " - " + eObj.dHrsDays + "" + arrival;
                    }
                    else
                    {
                        eObj.sPolicyName = "Non-Refundable";
                    }


                    if (eObj.Mode == "Add")
                    {
                        eObj.iPropId      = Convert.ToInt32(Session["PropId"]);
                        eObj.dtActionDate = DateTime.Now;
                        eObj.cStatus      = "A";

                        eObj.iActionBy = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId;
                        if (BL_tblPropertyCancellationPolicyMap.CheckIfPolicyNameExists(eObj.sPolicyName, eObj.iPropId))
                        {
                            result = new { st = 0, msg = "Policy Name already exists." };
                        }
                        else
                        {
                            int j = BL_tblPropertyCancellationPolicyMap.AddRecord(eObj);
                            if (j == 1)
                            {
                                result = new { st = 1, msg = "Added successfully." };
                            }
                            else
                            {
                                result = new { st = 0, msg = "Kindly try after some time." };
                            }
                        }
                    }
                    else if (eObj.Mode == "Edit")
                    {
                        if (BL_tblPropertyCancellationPolicyMap.CheckIfPolicyNameExistsOnUpdate(eObj.sPolicyName.Replace(".00", ""), eObj.iCancellationPolicyId, eObj.iPropId))
                        {
                            result = new { st = 0, msg = "This Policy Name already exists." };
                        }
                        else
                        {
                            int j = BL_tblPropertyCancellationPolicyMap.UpdateRecord(eObj);
                            if (j == 1)
                            {
                                result = new { st = 1, msg = "Updated successfully." };
                            }
                            else
                            {
                                result = new { st = 0, msg = "Kindly try after some time." };
                            }
                        }
                    }
                }
                else
                {
                    result = new { st = 0, msg = "Kindly try after some time." };
                }
            }
            catch (Exception)
            {
                result = new { st = 0, msg = "Kindly try after some time." };
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }