Exemplo n.º 1
0
        public string AddRoomTypeRateTypeMapping(RoomTypeRateTypeMappingVM model)
        {
            string mappingId = string.Empty;

            SqlParameter[] parameters =
            {
                new SqlParameter {
                    ParameterName = "@RoomTypeId", Value = model.RoomTypeId
                },
                new SqlParameter {
                    ParameterName = "@RateTypeId", Value = model.RateTypeId
                },
                new SqlParameter {
                    ParameterName = "@Description", Value = model.Description
                },
                new SqlParameter {
                    ParameterName = "@Amount", Value = model.Amount
                },
                new SqlParameter {
                    ParameterName = "@IsWeekEndPrice", Value = model.IsWeekEndPrice
                },
                new SqlParameter {
                    ParameterName = "@IsActive", Value = model.IsActive
                },
                new SqlParameter {
                    ParameterName = "@CreatedBy", Value = model.CreatedBy
                }
            };

            mappingId = Convert.ToString(DALHelper.ExecuteScalar("AddRoomTypeRateTypeMapping", parameters));

            return(mappingId);
        }
Exemplo n.º 2
0
        public ActionResult Edit(Guid id)
        {
            var mapping = rateRepository.GetRoomTypeRateTypeMappingId(id);

            RoomTypeRateTypeMappingVM model = new RoomTypeRateTypeMappingVM();

            if (mapping != null && mapping.Count > 0)
            {
                model = mapping[0];

                var roomTypeList = new SelectList(roomTypeRepository.GetRoomType(string.Empty), "Id", "RoomTypeCode");
                var ratetypeList = new SelectList(rateTypeRepository.GetRateType(string.Empty), "ID", "RateTypeCode");

                ViewBag.RoomTypeList = roomTypeList;
                ViewBag.RateTypeList = ratetypeList;

                return(View(model));
            }

            return(RedirectToAction("List"));
        }
        public ActionResult Create(RoomTypeVM model)
        {
            try
            {
                string roomTypeId = string.Empty;
                model.CreatedBy = LogInManager.LoggedInUserId;

                #region Check Room Type Code Available.

                if (this.CheckRoomTypeCodeAvailable(model.Id, model.RoomTypeCode) == false)
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = string.Format("Room Type Code : {0} already exist.", model.RoomTypeCode)
                    }, JsonRequestBehavior.AllowGet));
                }

                #endregion

                roomTypeId = roomTypeRepository.AddRoomType(model);

                if (!string.IsNullOrWhiteSpace(roomTypeId))
                {
                    #region Add Rate (Default 100) for each Rate Type.

                    var rateTypes = rateTypeRepository.GetRateType(string.Empty);

                    if (rateTypes != null && rateTypes.Count > 0)
                    {
                        foreach (var rateType in rateTypes)
                        {
                            RoomTypeRateTypeMappingVM roomTypeRateTypeMapping = new RoomTypeRateTypeMappingVM();
                            roomTypeRateTypeMapping.RoomTypeId = Guid.Parse(roomTypeId);
                            roomTypeRateTypeMapping.RateTypeId = rateType.Id;
                            roomTypeRateTypeMapping.Amount     = 100; //Default Price.
                            roomTypeRateTypeMapping.IsActive   = true;
                            roomTypeRateTypeMapping.CreatedBy  = LogInManager.LoggedInUserId;

                            rateRepository.AddRoomTypeRateTypeMapping(roomTypeRateTypeMapping);
                        }
                    }

                    #endregion

                    return(Json(new
                    {
                        IsSuccess = true,
                        data = new
                        {
                            RoomTypeId = model.Id
                        }
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "Room Type details not saved successfully."
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "Create");
                return(Json(new
                {
                    IsSuccess = false,
                    errorMessage = e.Message
                }));
            }
        }
Exemplo n.º 4
0
        public ActionResult Create(RoomTypeRateTypeMappingVM model)
        {
            try
            {
                string source    = string.Empty;
                string url       = string.Empty;
                string qid       = string.Empty;
                string mappingId = string.Empty;

                model.IsWeekEndPrice = false;

                #region  Check Source Parameters
                if (Request.Form["Source"] != null && !string.IsNullOrWhiteSpace(Convert.ToString(Request.Form["Source"])))
                {
                    source = Convert.ToString(Request.Form["Source"]);

                    if (source == "WeekDayPrice")
                    {
                        TempData["TabName"] = "WeekDayPrice";
                        url = Url.Action("ManagePrice", "Rate");
                        model.IsWeekEndPrice = false;
                    }
                    else if (source == "WeekEndPrice")
                    {
                        TempData["TabName"] = "WeekEndPrice";
                        url = Url.Action("ManagePrice", "Rate");

                        model.IsWeekEndPrice = true;
                    }
                }
                #endregion


                model.CreatedBy = LogInManager.LoggedInUserId;

                #region Check Room Type Rate Type Mapping Available.

                if (this.CheckRoomTypeRateTypeMappingAvailable(model.Id, model.RoomTypeId, model.RateTypeId, model.IsWeekEndPrice) == false)
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = string.Format("Selected mapping already exist.")
                    }, JsonRequestBehavior.AllowGet));
                }

                #endregion

                mappingId = rateRepository.AddRoomTypeRateTypeMapping(model);

                #region Check External URL
                if (!string.IsNullOrWhiteSpace(url))
                {
                    return(Json(new
                    {
                        IsSuccess = true,
                        IsExternalUrl = true,
                        data = url
                    }, JsonRequestBehavior.AllowGet));
                }
                #endregion

                if (!string.IsNullOrWhiteSpace(mappingId))
                {
                    return(Json(new
                    {
                        IsSuccess = true,
                        data = new
                        {
                            MappingId = model.Id
                        }
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "Rate details not saved successfully."
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "Create");
                return(Json(new
                {
                    IsSuccess = false,
                    errorMessage = e.Message
                }));
            }
        }