예제 #1
0
        public ActionResult Index()
        {
            etblPropertyAmenitiesMap obj = new etblPropertyAmenitiesMap();

            try
            {
                int id = Convert.ToInt32(Session["PropId"]);
                obj                     = BL_tblPropertyAmenitiesMap.GetSingleRecordById(id);
                obj.iPropId             = id;
                obj.CommonServicesItems = BL_tblHotelCommonServiceM.GetPropertyCommonServices(obj.sHotelCommonServices);
                obj.ConveniencesItems   = BL_tblHotelConvenienceM.GetPropertyConveniences(obj.sHotelConvenience);
                obj.LeisureItems        = BL_tblHotelLeisureM.GetPropertyLeisure(obj.sHotelLeisure);
                obj.MeetingsItems       = BL_tblHotelMeetingM.GetPropertyMeetings(obj.sHotelMeetings);
                obj.HotelAmenities      = BL_tblHotelAmenityM.GetHotelAmenities();
                obj.HotelParkingsRadio  = BL_tblHotelParkingM.GetHotelParkingsRadio();
                obj.HotelParkingsItems  = BL_tblHotelParkingM.GetHotelParkingsCheckBox(obj.sHotelParkings);
                //obj.bAirportTransferAvalible = true;
                //List<etblPropertyParkingMap> results = BL_tblPropertyAmenitiesMap.GetPropertyParkingList(id);
                //obj.JsonParkingMapData = OneFineRateAppUtil.clsUtils.ConvertToJson(results);
            }
            catch (Exception)
            {
            }
            return(View(obj));
        }
예제 #2
0
        public ActionResult AddPartial()
        {
            etblPropertyAmenitiesMap obj = new etblPropertyAmenitiesMap();
            int id = Convert.ToInt32(Session["PropId"]);

            obj         = BL_tblPropertyAmenitiesMap.GetSingleRecordById(id);
            obj.iPropId = id;
            List <etblPropertyParkingMap> results = BL_tblPropertyAmenitiesMap.GetPropertyParkingList(id);

            obj.JsonParkingMapData = OneFineRateAppUtil.clsUtils.ConvertToJson(results);
            return(PartialView("PropertyParking", obj));
        }
        //Get Single Record
        public static etblPropertyAmenitiesMap GetSingleRecordById(int id)
        {
            etblPropertyAmenitiesMap eobj = new etblPropertyAmenitiesMap();

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                var dbobj = db.tblPropertyAmenitiesMaps.SingleOrDefault(u => u.iPropId == id);
                if (dbobj != null)
                {
                    eobj = (etblPropertyAmenitiesMap)OneFineRateAppUtil.clsUtils.ConvertToObject(dbobj, eobj);
                }
            }
            return(eobj);
        }
예제 #4
0
        public ActionResult Modify(etblPropertyAmenitiesMap prop)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        prop.dtActionDate = DateTime.Now;
                        //get all common services comma seperated
                        if (prop.SelectedCommonServices != null)
                        {
                            prop.sHotelCommonServices = prop.SelectedCommonServices.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                        }
                        //get all Convenience comma seperated
                        if (prop.SelectedConveniences != null)
                        {
                            prop.sHotelConvenience = prop.SelectedConveniences.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                        }
                        //get all Leisure comma seperated
                        if (prop.SelectedLeisure != null)
                        {
                            prop.sHotelLeisure = prop.SelectedLeisure.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                        }
                        //get all Meetings comma seperated
                        if (prop.SelectedMeetings != null)
                        {
                            prop.sHotelMeetings = prop.SelectedMeetings.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                        }
                        //get all Hotel Parkings comma seperated
                        if (prop.SelectedHotelParkings != null)
                        {
                            prop.sHotelParkings = prop.SelectedHotelParkings.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                        }


                        if (prop.SelectedParkings != null)
                        {
                            JArray jArray = (JArray)JsonConvert.DeserializeObject(prop.SelectedParkings.Replace("\\", "\""));
                            if (jArray != null)
                            {
                                List <etblPropertyParkingMap> lstPropertyParkingMap = new List <etblPropertyParkingMap>();
                                foreach (var item in jArray)
                                {
                                    lstPropertyParkingMap.Add(new etblPropertyParkingMap()
                                    {
                                        iPropId       = prop.iPropId,
                                        sCarName      = Convert.ToString(item["Name"]),
                                        cAirportRail  = Convert.ToString(item["Type"]),
                                        bIsFree       = Convert.ToBoolean(item["comp"]),
                                        dOnewayCharge = Convert.ToDecimal(item["oneway"]),
                                        dTwowayCharge = Convert.ToDecimal(item["twoway"]),
                                        dtActionDate  = DateTime.Now,
                                        iActionBy     = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId
                                    });
                                }
                                prop.HotelParkingsMapList = lstPropertyParkingMap;
                            }
                        }
                        prop.iActionBy = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId;

                        int result = BL_tblPropertyAmenitiesMap.UpdateRecord(prop);
                        if (result == 1)
                        {
                            TempData["msg"] = "Amenities/Services Modified Successfully";
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
            catch (Exception)
            {
            }
            return(View("Edit", prop));
        }
        //Update a record
        public static int UpdateRecord(etblPropertyAmenitiesMap eobj)
        {
            bool Type   = false;
            int  retval = 0;

            using (OneFineRateEntities dbnew = new OneFineRateEntities())
            {
                try
                {
                    var dbobj = dbnew.tblPropertyAmenitiesMaps.SingleOrDefault(u => u.iPropId == eobj.iPropId);
                    if (dbobj != null)
                    {
                        Type = true;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    //remove old mapings
                    db.tblPropertyParkingMaps.RemoveRange(db.tblPropertyParkingMaps.Where(x => x.iPropId == eobj.iPropId));

                    //Add mapings
                    if (eobj.HotelParkingsMapList != null)
                    {
                        db.tblPropertyParkingMaps.AddRange(eobj.HotelParkingsMapList.Select(x => new tblPropertyParkingMap()
                        {
                            iPropId       = x.iPropId,
                            sCarName      = x.sCarName,
                            cAirportRail  = x.cAirportRail,
                            bIsFree       = x.bIsFree,
                            dOnewayCharge = x.dOnewayCharge,
                            dTwowayCharge = x.dTwowayCharge,
                            dtActionDate  = x.dtActionDate,
                            iActionBy     = x.iActionBy
                        }).ToList());
                    }
                    if (Type)
                    {
                        OneFineRate.tblPropertyAmenitiesMap obj = (OneFineRate.tblPropertyAmenitiesMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyAmenitiesMap());
                        db.tblPropertyAmenitiesMaps.Attach(obj);
                        db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        retval = 1;
                    }
                    else
                    {
                        OneFineRate.tblPropertyAmenitiesMap dbuser = (OneFineRate.tblPropertyAmenitiesMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyAmenitiesMap());
                        db.tblPropertyAmenitiesMaps.Add(dbuser);
                        db.SaveChanges();
                        retval = 1;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retval);
        }