public ActionResult Create(HotelCityInfoAssociation model)
        {
            var viewModel = new HotelCityInfoAssociation
            {
                HotelNameList     = _HotelInfoRepo.HotelInfoList(),
                HotelCityInfoList = _CityInfoRepo.HotelCityInfoList(),
            };

            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }
            else
            {
                //Htl_HotelCityInfoAssociation obj = new Htl_HotelCityInfoAssociation();
                //obj.HotelId = model.HotelId;
                //obj.CityId = model.CityId;
                //obj.Latitude = model.Latitude;
                //obj.Longitude = model.Longitude;

                _HotelInfoRepo.HotelCityInfoAssociationAdd(model);
            }

            ViewData["success"] = "Record successfully added.";

            return(View(viewModel));
            //return View("List", viewModel);
        }
Ejemplo n.º 2
0
        public ActionResult Create(HotelInfos model, FormCollection frmColl)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            else
            {
                bool Status = model.StatusId == 0 ? true : false;

                string strHotelRoomTypeList = string.Empty, strHotelFacityList = string.Empty, strHotelCityInfoList = string.Empty, strHotelAdditionalChargeList = string.Empty;
                string sfileName = string.Empty;

                var httpFileCollection = Request.Files;
                for (int i = 0; i < httpFileCollection.Count; i++)
                {
                    var httpPostedFile = httpFileCollection[i];
                    if (httpPostedFile.ContentLength > 0)
                    {
                        string FileExtension = Path.GetExtension(httpPostedFile.FileName);
                        int    FileSize      = httpPostedFile.ContentLength;

                        if (FileSize <= ATLTravelPortal.Helpers.ApplicationSettings.GetMaxPhotoSizeToUpload())
                        {
                            switch (httpPostedFile.ContentType)
                            {
                            case "image/pjpeg":
                            case "image/jpeg":
                            case "image/gif":
                            case "image/png":
                                sfileName = Guid.NewGuid().ToString() + FileExtension;
                                string sFilePath = Server.MapPath("/HotelUploads/Logo/");

                                if (!Directory.Exists(Server.MapPath("~/HotelUploads/")))
                                {
                                    Directory.CreateDirectory(Server.MapPath("~/HotelUploads/"));
                                }
                                if (!Directory.Exists(Server.MapPath("~/HotelUploads/Logo/")))
                                {
                                    Directory.CreateDirectory(Server.MapPath("~/HotelUploads/Logo/"));
                                }

                                string location = sFilePath + "/" + sfileName;
                                httpPostedFile.SaveAs(location);
                                break;

                            default:
                                return(Content("Invalid Image Type"));
                            }
                        }
                    }
                }

                foreach (string item in frmColl)
                {
                    if (item.Contains("chkbox"))
                    {
                        if (item.Contains("roomtype"))
                        {
                            string[] arrayCheckBox = item.Split('_');

                            if (strHotelRoomTypeList == "")
                            {
                                strHotelRoomTypeList = arrayCheckBox[1].ToString();
                            }
                            else
                            {
                                strHotelRoomTypeList = strHotelRoomTypeList + "," + arrayCheckBox[1].ToString();
                            }
                        }
                        else if (item.Contains("facility"))
                        {
                            string[] arrayCheckBox = item.Split('_');
                            if (strHotelFacityList == "")
                            {
                                strHotelFacityList = arrayCheckBox[1].ToString();
                            }
                            else
                            {
                                strHotelFacityList = strHotelFacityList + "," + arrayCheckBox[1].ToString();
                            }
                        }
                        else if (item.Contains("city"))
                        {
                            string[] arrayCheckBox = item.Split('_');
                            if (strHotelCityInfoList == "")
                            {
                                strHotelCityInfoList = arrayCheckBox[1].ToString();
                            }
                            else
                            {
                                strHotelCityInfoList = strHotelCityInfoList + "," + arrayCheckBox[1].ToString();
                            }
                        }
                        else if (item.Contains("additionalcharge"))
                        {
                            string[] arrayCheckBox = item.Split('_');
                            if (strHotelAdditionalChargeList == "")
                            {
                                strHotelAdditionalChargeList = arrayCheckBox[1].ToString();
                            }
                            else
                            {
                                strHotelAdditionalChargeList = strHotelAdditionalChargeList + "," + arrayCheckBox[1].ToString();
                            }
                        }
                    }
                }



                Htl_HotelInfos obj = new Htl_HotelInfos();
                var            ts  = (TravelSession)Session["TravelSessionInfo"];
                obj.HotelName = model.HotelName;
                obj.CountryId = model.HotelInfo.CountryId;
                //obj.CountryList = model.CountryList;



                //obj.HotelType = model.HotelType;
                //obj.HotelTypeList = model.HotelTypeList;

                //obj.HotelTypeList = _HotelTypeInfoRepo.HotelTypeInfoList();

                obj.HotelCode     = model.HotelCode;
                obj.OptionalEmail = model.OptionalEmail;
                obj.Address       = model.Address;
                obj.Web           = model.Web;
                obj.Phone         = model.Phone;
                obj.Email         = model.Email;
                obj.Details       = model.Details;
                obj.OptionalPhone = model.OptionalPhone;
                obj.isActive      = model.isActive;
                obj.isDeleted     = false;
                obj.Logo          = model.Logo;
                obj.CreatedBy     = App_Class.AppSession.LogUserID;
                obj.CreatedDate   = DateTime.Now;

                long Hotelid = _HotelInfoRepo.HotelInfoAdd(obj);


                Htl_HotelContactInfos objs = new Htl_HotelContactInfos();
                objs.HotelId            = Hotelid;
                objs.OwnerFullName      = model.HotelContactInfo.OwnerFullName;
                objs.OwnerDesignationId = model.HotelContactInfo.OwnerDesignationId;

                objs.OwnerEmail           = model.HotelContactInfo.OwnerEmail;
                objs.OwnerMobile          = model.HotelContactInfo.OwnerMobile;
                objs.OwnerLandline        = model.HotelContactInfo.OwnerLandline;
                objs.OwnerTempAddress     = model.HotelContactInfo.OwnerTempAddress;
                objs.OwnerPermAddress     = model.HotelContactInfo.OwnerPermAddress;
                objs.OwnerDOB             = model.HotelContactInfo.OwnerDOB;
                objs.ContactFullName      = model.HotelContactInfo.ContactFullName;
                objs.ContactEmail         = model.HotelContactInfo.ContactEmail;
                objs.ContactMobile        = model.HotelContactInfo.ContactMobile;
                objs.ContactLandline      = model.HotelContactInfo.ContactLandline;
                objs.ContactTempAddress   = model.HotelContactInfo.ContactTempAddress;
                objs.ContactPermAddress   = model.HotelContactInfo.ContactPermAddress;
                objs.ContactDOB           = model.HotelContactInfo.ContactDOB;
                objs.ContactDesignationId = model.HotelContactInfo.ContactDesignationId;
                objs.isDeleted            = false;
                objs.CreatedBy            = App_Class.AppSession.LogUserID;
                objs.CreatedDate          = DateTime.Now;
                _HotelInfoRepo.HotelContactInfoAdd(objs);


                Htl_RoomTypeAssociation c = new Htl_RoomTypeAssociation();
                c.HotelId = Hotelid;
                string[] sring = strHotelRoomTypeList.Split(',');
                foreach (string strs in sring)
                {
                    if (string.IsNullOrEmpty(strs))
                    {
                        obj.CountryId = model.HotelInfo.CountryId;
                        //obj.CountryList = model.CountryList;
                    }

                    else
                    {
                        c.HotelId         = Hotelid;
                        c.HotelRoomTypeId = Convert.ToInt32(strs);
                        _HotelInfoRepo.HotelRoomTypeAssociationAdd(c);
                    }
                }
                c.HotelId = Hotelid;



                HotelCityInfoAssociation p = new HotelCityInfoAssociation();
                p.HotelId = Hotelid;


                string[] str = strHotelCityInfoList.Split(',');
                foreach (string strs in str)
                {
                    if (string.IsNullOrEmpty(strs))
                    {
                        obj.CountryId = model.HotelInfo.CountryId;
                        //obj.CountryList = model.CountryList;
                    }

                    else
                    {
                        p.HotelId = Hotelid;
                        p.CityId  = Convert.ToInt32(strs);
                        _HotelInfoRepo.HotelCityInfoAssociationAdd(p);
                    }
                }
                p.HotelId = Hotelid;

                Htl_HotelAdditionalChargeAssociation a = new Htl_HotelAdditionalChargeAssociation();
                a.HotelId = Hotelid;
                string[] strg = strHotelAdditionalChargeList.Split(',');
                foreach (string strs in strg)
                {
                    if (string.IsNullOrEmpty(strs))
                    {
                        obj.CountryId = model.HotelInfo.CountryId;
                        //obj.CountryList = model.CountryList;
                    }

                    else
                    {
                        a.HotelId  = Hotelid;
                        a.ChargeId = Convert.ToInt32(strs);
                        _HotelInfoRepo.HotelAdditionalChargeAssociationAdd(a);
                    }
                }

                Htl_HotelFacilityAssociation b = new Htl_HotelFacilityAssociation();
                b.HotelId = Hotelid;
                string[] strng = strHotelFacityList.Split(',');
                foreach (string strs in strng)
                {
                    if (string.IsNullOrEmpty(strs))
                    {
                        obj.CountryId = model.HotelInfo.CountryId;
                        //obj.CountryList = model.CountryList;
                    }

                    else
                    {
                        b.HotelId    = Hotelid;
                        b.FacilityId = Convert.ToInt32(strs);
                        _HotelInfoRepo.HotelFacilityAssociationAdd(b);
                    }
                }

                //Htl_RoomTypeAssociation c = new Htl_RoomTypeAssociation();
                //c.HotelId = Hotelid;
                //string[] sring = strHotelRoomTypeList.Split(',');
                //foreach (string strs in sring)
                //    if (string.IsNullOrEmpty(strs))
                //    {
                //        return View("Create");
                //    }

                //    else
                //    {
                //        c.HotelId = Hotelid;
                //        c.HotelRoomTypeId = Convert.ToInt32(strs);
                //        _HotelInfoRepo.HotelRoomTypeAssociationAdd(c);
                //    }
                //c.HotelId = Hotelid;
                return(RedirectToAction("List"));
            }
        }