Ejemplo n.º 1
0
        public void Execute(IJobExecutionContext context)
        {
            PropertyModel PropertyModel = new Models.PropertyModel();
            JobDataMap    dataMap       = context.JobDetail.JobDataMap;

            int         PropertyId         = Convert.ToInt32(dataMap.GetString("PropertyId"));
            string      Subject            = dataMap.GetString("Subject");
            string      Body               = dataMap.GetString("Body");
            string      PropertyTypeStatus = dataMap.GetString("PropertyTypeStatus");
            CommonClass CommonClass        = new Services.CommonClass();
            string      QStr               = "";
            DataTable   dt = new DataTable();

            QStr = "select p.PropertyId,p.Style,p.LocationPrefered,p.PropertyType,c.TrebId,c.FirstName,c.MiddleName,c.LastName,c.EmailId from Property p,Customer c where  p.CustomerId=c.CustomerId and p.PropertyId=" + PropertyId;
            dt   = CommonClass.GetDataSet(QStr).Tables[0];

            if (dt.Rows.Count > 0)
            {
                string FirstName = dt.Rows[0]["FirstName"].ToString() + " " + dt.Rows[0]["MiddleName"].ToString() + " " + dt.Rows[0]["LastName"].ToString();
                string EmailId   = dt.Rows[0]["EmailId"].ToString();
                PropertyModel.PropertyTypeStatus = PropertyTypeStatus;
                PropertyModel.Style            = dt.Rows[0]["Style"].ToString();
                PropertyModel.PropertyType     = dt.Rows[0]["PropertyType"].ToString();
                PropertyModel.LocationPrefered = dt.Rows[0]["LocationPrefered"].ToString();
                PropertyModel.CustomerTrebId   = dt.Rows[0]["TrebId"].ToString();


                SendMailToUser(FirstName, EmailId, PropertyModel);
                SendMailToAdmin(FirstName, EmailId, PropertyModel, Subject, Body);
            }
        }
        //
        // GET: /PropertyEdit/
        public ActionResult Index(long?id, string tab)
        {
            try
            {
                Models.PropertyModel prprty = new Models.PropertyModel();
                prprty.CheckInhr  = "02";
                prprty.CheckOuthr = "12";
                if (id.HasValue && id.Value > 0)
                {
                    long propertyId = id.Value;
                    long ownerId    = BLayer.User.GetUserId(User.Identity.Name);
                    if (!BLayer.Property.IsOwnerProperty(id.Value, ownerId))
                    {
                        return(Redirect("PropertyList")); //current user does not own this property
                    }
                    prprty = GetDetails(id.Value);
                }
                else
                {
                    long ownerId = 0; // = BLayer.User.GetUserId(User.Identity.GetUserId);
                    long.TryParse(User.Identity.GetUserId(), out ownerId);
                    prprty.OwnerId    = ownerId;
                    prprty.PropertyId = 0;
                    List <CLayer.Address> adr = BLayer.Address.GetOnUser(ownerId);
                    if (adr.Count > 0)
                    {
                        prprty.State   = adr[0].State;
                        prprty.CityId  = adr[0].CityId;
                        prprty.City    = adr[0].City;
                        prprty.Country = adr[0].CountryId;
                        prprty.LoadPlaces();
                    }
                }
                if (tab == null || tab == "")
                {
                    prprty.ActiveTab = "home";
                }
                else
                {
                    prprty.ActiveTab = tab;
                }

                return(View(prprty));
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/ErrorPage"));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Property()
        {
            var cus = Session["UserCompany"] as UserCompany;

            Models.PropertyModel           pm = new Models.PropertyModel();
            List <Models.ShiftType>        sl = new List <Models.ShiftType>();
            List <Models.AnnouncementType> al = new List <Models.AnnouncementType>();
            var dbo = ProjeDB.DBO.GetInstance();

            using (ProjeEntities db = new ProjeEntities())
            {
                var shift = db.Companies.Include("CompanyShifts").Include("CompanyShifts.Shift").Where(x => x.Id == cus.CompanyId).ToList();
                foreach (var item in shift)
                {
                    foreach (var item2 in item.CompanyShifts)
                    {
                        var p = dbo.getPrice(item2.Shift.Id);
                        Models.ShiftType s = new Models.ShiftType();
                        s.Id       = item2.Shift.Id;
                        s.Name     = item2.Shift.Name;
                        s.Price    = (int)p.Price;
                        s.CardName = item2.Shift.ShiftNumber;
                        sl.Add(s);
                    }
                }

                var ann = db.Companies.Include("CompanyAnnouncements").Include("CompanyAnnouncements.Announcement").Where(z => z.Id == cus.CompanyId).ToList();

                foreach (var item in ann)
                {
                    foreach (var item2 in item.CompanyAnnouncements)
                    {
                        Models.AnnouncementType a = new Models.AnnouncementType();
                        a.Id   = item2.Announcement.Id;
                        a.Name = item2.Announcement.Name;
                        al.Add(a);
                    }
                }

                pm.ShiftList = sl;
                pm.AnnList   = al;

                return(View(pm));
            }
        }
        public ActionResult AccommodationSave(Models.AccommodationModel data)
        {
            try
            {
                string userid = User.Identity.GetUserId();
                long   id     = 0;
                long.TryParse(userid, out id);
                if (ModelState.IsValid)
                {
                    CLayer.Accommodation accmdtn = new CLayer.Accommodation()
                    {
                        AccommodationId     = data.AccommodationId,
                        PropertyId          = data.PropertyId,
                        AccommodationTypeId = data.AccommodationTypeId,
                        StayCategoryId      = data.StayCategoryId,
                        AccommodationCount  = data.AccommodationCount,
                        Description         = data.Description,

                        MaxNoOfPeople       = data.MaxNoOfPeople,
                        MaxNoOfChildren     = data.MaxNoOfChildren,
                        MinNoOfPeople       = data.MinNoOfPeople,
                        BedRooms            = data.BedRooms,
                        Area                = data.Area,
                        Status              = data.Status,
                        TotalAccommodations = data.TotalAccommodations,
                        UpdatedById         = id
                    };
                    long accId = BLayer.Accommodation.Save(accmdtn);
                    Models.PropertyModel property = GetDetails(data.PropertyId);
                    property.ActiveTab = "accommodation";
                    property.Accommodations.Accommodation = AccommodationGet(accId);
                    //property.Accommodations.Accommodation.ActiveTab = "acc";
                    return(View("Index", property));
                    //return RedirectToAction("Index", new { id = data.PropertyId });
                }
                return(Redirect("~/ErrorPage"));
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/ErrorPage"));
            }
        }
 public ActionResult PictureDelete(long id)
 {
     try
     {
         CLayer.PropertyFiles pf = BLayer.PropertyFiles.Get(id);
         BLayer.PropertyFiles.Delete(id);
         if (System.IO.File.Exists(Server.MapPath("~/Files/Property/" + pf.PropertyId.ToString() + "/" + pf.FileName)))
         {
             System.IO.File.Delete(Server.MapPath("~/Files/Property/" + pf.PropertyId.ToString() + "/" + pf.FileName));
         }
         Models.PropertyModel property = GetDetails(pf.PropertyId);
         property.ActiveTab = "gallery";
         return(View("Index", property));
         //return RedirectToAction("Index", new { id = pf.PropertyId });
     }
     catch (Exception ex)
     {
         Common.LogHandler.HandleError(ex);
         return(Redirect("~/ErrorPage"));
     }
 }
 public ActionResult AccommodationPictureDelete(long id)
 {
     try
     {
         CLayer.AccommodationFiles pf = BLayer.AccommodationFiles.Get(id);
         BLayer.AccommodationFiles.Delete(id);
         if (System.IO.File.Exists(Server.MapPath("~/Files/Property/Accommodation/" + pf.AccommodationId.ToString() + "/" + pf.FileName)))
         {
             System.IO.File.Delete(Server.MapPath("~/Files/Property/Accommodation/" + pf.AccommodationId.ToString() + "/" + pf.FileName));
         }
         CLayer.Accommodation ac       = BLayer.Accommodation.Get(pf.AccommodationId);
         Models.PropertyModel property = GetDetails(ac.PropertyId);
         property.ActiveTab = "accommodation";
         property.Accommodations.Accommodation           = AccommodationGet(pf.AccommodationId);
         property.Accommodations.Accommodation.ActiveTab = "pictures";
         return(View("Index", property));
         //return RedirectToAction("Index", new { id = ac.PropertyId });
     }
     catch (Exception ex)
     {
         Common.LogHandler.HandleError(ex);
         return(Redirect("~/ErrorPage"));
     }
 }
        public ActionResult AccommodationPictureSave(Models.AccommodationPicturesModel data)
        {
            try
            {
                if (data.AccommodationId == 0)
                {
                    Models.PropertyModel property = GetDetails(data.PropertyId);
                    property.ActiveTab = "accommodation";
                    property.Accommodations.Accommodation           = AccommodationGet(data.AccommodationId);
                    property.Accommodations.Accommodation.ActiveTab = "pictures";
                    return(View("Index", property));
                }

                if (ModelState.IsValid)
                {
                    #region Save
                    string FileNamePart = data.AccommodationId.ToString() + DateTime.Now.ToString("ddMMyyyyHHmmss");
                    CLayer.AccommodationFiles acmdtn = new CLayer.AccommodationFiles()
                    {
                        AccommodationId = data.AccommodationId,
                        FileId          = data.FileId,
                        FileName        = FileNamePart + System.IO.Path.GetFileNameWithoutExtension(data.AccommodationPhoto.FileName) + ".jpg"
                    };

                    if (data.AccommodationPhoto != null && data.AccommodationPhoto.ContentLength > 0)
                    {
                        int      Sizevalue             = Convert.ToInt32(ConfigurationManager.AppSettings.Get("FileUploadSizeInMB"));
                        int      MaxContentLength      = 1024 * 1024 * Sizevalue; //3 MB
                        string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".jpeg" };

                        if (!AllowedFileExtensions.Contains(data.AccommodationPhoto.FileName.Substring(data.AccommodationPhoto.FileName.LastIndexOf('.'))))
                        {
                            ModelState.AddModelError(string.Empty, "Please use files of type: " + string.Join(", ", AllowedFileExtensions));
                        }
                        else if (data.AccommodationPhoto.ContentLength > MaxContentLength)
                        {
                            ModelState.AddModelError(string.Empty, "Your file is too large, maximum allowed size is: " + MaxContentLength + " MB");
                        }
                        else
                        {
                            var fileName = FileNamePart + System.IO.Path.GetFileName(data.AccommodationPhoto.FileName); //uploaded file from UI

                            if (!System.IO.Directory.Exists(Server.MapPath("~/Files/Temp/")))
                            {
                                System.IO.Directory.CreateDirectory(Server.MapPath("~/Files/Temp/"));
                            }
                            var path = System.IO.Path.Combine(Server.MapPath("~/Files/Temp/"), fileName);
                            data.AccommodationPhoto.SaveAs(path);


                            int   maxHeight = Convert.ToInt32(ConfigurationManager.AppSettings.Get("MaxImgHeight"));
                            Image tempimage = Image.FromFile(path);

                            Image resized = Common.Utils.ScaleImage(tempimage, maxHeight);

                            //var fileName = acmdtn.FileName;
                            if (!System.IO.Directory.Exists(Server.MapPath("~/Files/Property/Accommodation/" + data.AccommodationId.ToString() + "/")))
                            {
                                System.IO.Directory.CreateDirectory(Server.MapPath("~/Files/Property/Accommodation/" + data.AccommodationId.ToString() + "/"));
                            }
                            var path2 = System.IO.Path.Combine(Server.MapPath("~/Files/Property/Accommodation/" + data.AccommodationId.ToString() + "/"), acmdtn.FileName);
                            resized.Save(path2, System.Drawing.Imaging.ImageFormat.Jpeg);
                            try
                            {
                                resized.Dispose();
                                tempimage.Dispose();
                                if (System.IO.File.Exists(path))
                                {
                                    System.IO.File.Delete(path);
                                }
                            }
                            catch
                            {
                            }
                            BLayer.AccommodationFiles.Save(acmdtn);
                            ModelState.Clear();
                        }
                    }
                    #endregion
                    Models.PropertyModel property = GetDetails(data.PropertyId);
                    property.ActiveTab = "accommodation";
                    property.Accommodations.Accommodation           = AccommodationGet(data.AccommodationId);
                    property.Accommodations.Accommodation.ActiveTab = "pictures";
                    return(View("Index", property));
                    //return RedirectToAction("Index", new { id = data.PropertyId });
                }
                return(Redirect("~/ErrorPage"));
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/ErrorPage"));
            }
        }
        public async Task <ActionResult> SaveDetails(Models.PropertyModel data)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (data.PropertyFor == 0)
                    {
                        data.PropertyFor = 3;
                    }
                    data.CheckInTime  = data.CheckInhr + ":" + data.CheckInmin + " " + data.CheckInclock;
                    data.CheckOutTime = data.CheckOuthr + ":" + data.CheckOutmin + " " + data.CheckOutClock;
                    //data.Description != "" &&
                    //if (data.Description.Length > 8000) data.Description = data.Description.Substring(0, 8000);
                    CLayer.Property prprty = new CLayer.Property()
                    {
                        PropertyId  = data.PropertyId,
                        Title       = data.Title,
                        Description = data.Description,
                        Location    = data.Location,
                        Status      = (CLayer.ObjectStatus.StatusType)data.Status,
                        OwnerId     = BLayer.User.GetUserId(User.Identity.Name),
                        Address     = data.Address,
                        Country     = data.Country,
                        // CountryId=data.CountryId,
                        State            = data.State,
                        City             = data.City,
                        CityId           = data.CityId,
                        ZipCode          = data.ZipCode,
                        Email            = data.Email,
                        DistanceFromCity = data.DistanceFromCity,
                        Phone            = data.Phone,
                        Mobile           = data.Mobile,
                        CheckInTime      = data.CheckInTime,
                        CheckOutTime     = data.CheckOutTime,
                        CheckInhr        = data.CheckInhr,
                        CheckInmin       = data.CheckInmin,
                        CheckInclock     = data.CheckInclock,
                        CheckOuthr       = data.CheckOuthr,
                        CheckOutmin      = data.CheckOutmin,
                        CheckOutClock    = data.CheckOutClock,
                        AgeLimit         = data.AgeLimit,
                        PageTitle        = data.PageTitle,
                        MetaDescription  = data.MetaDescription,
                        PropertyFor      = data.PropertyFor
                    };
                    string loc = "";
                    try
                    {
                        string statename = BLayer.State.Get(data.State).Name;
                        string cityname;

                        if (data.CityId < 1)
                        {
                            cityname = data.City;
                        }
                        else
                        {
                            cityname    = BLayer.City.Get(data.CityId).Name;
                            data.City   = cityname;
                            prprty.City = cityname;
                        }
                        string Countryname = BLayer.Country.Get(data.Country).Name;
                        loc = cityname + "," + statename + "," + Countryname;
                        string qAdddress = data.Title + "," + data.Address + "," + loc;

                        Common.Utils.Location pos;

                        pos = await Common.Utils.GetLocation(qAdddress);

                        prprty.PositionLat = pos.Lattitude.ToString();
                        prprty.PositionLng = pos.Longitude.ToString();

                        //string apiQuery = BLayer.Settings.GetValue(CLayer.Settings.GOOGLE_API_QUERY);
                        //apiQuery = apiQuery.Replace("[ADDR]", HttpUtility.UrlEncode(qAdddress));
                        //apiQuery = apiQuery.Replace("[API]", BLayer.Settings.GetValue(CLayer.Settings.GOOGLE_API_KEY));

                        //System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
                        //string result = await client.GetStringAsync(apiQuery);
                        //System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                        //doc.LoadXml(result);
                        //string status = doc.SelectSingleNode("/GeocodeResponse/status").InnerText;
                        //if (status.ToUpper().Trim() == "OK")
                        //{
                        //    string lat = doc.SelectSingleNode("/GeocodeResponse/result/geometry/location/lat").InnerText;
                        //    string longitude = doc.SelectSingleNode("/GeocodeResponse/result/geometry/location/lng").InnerText;
                        //    prprty.PositionLat = lat;
                        //    prprty.PositionLng = longitude;
                        //}
                    }
                    catch (Exception ex)
                    {
                        Common.LogHandler.LogError(ex);
                    }
                    if (data.DistanceFromCity <= 0)
                    {
                        try
                        {
                            Common.Utils.Location pos;
                            pos = await Common.Utils.GetLocation(loc);

                            double lat, lng;
                            lat = lng = 0;
                            double.TryParse(prprty.PositionLat, out lat);
                            double.TryParse(prprty.PositionLng, out lng);
                            //  double val = Common.Utils.GetDistance(lat,lng, (double) pos.Lattitude,(double) pos.Longitude);
                            double val = Common.Utils.DistanceCalc(lat, lng, (double)pos.Lattitude, (double)pos.Longitude);
                            //val = val * 1000;
                            prprty.DistanceFromCity = (int)Math.Round(val, 1);
                            if (prprty.DistanceFromCity > 100)
                            {
                                prprty.DistanceFromCity = 0;
                            }
                        }
                        catch (Exception ex)
                        {
                            Common.LogHandler.LogError(ex);
                        }
                    }
                    else
                    {
                        prprty.DistanceFromCity = data.DistanceFromCity;
                    }

                    data.PropertyId = BLayer.Property.Save(prprty);
                    BLayer.Property.SetPosition(data.PropertyId, prprty.PositionLat, prprty.PositionLng);
                    ViewBag.Message = "Saved property.";
                    return(RedirectToAction("Index", new { id = data.PropertyId }));
                }
                else
                {
                    ViewBag.Message = "Error. Please try again";
                    return(View("Index", data));
                }
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/ErrorPage"));
            }
        }
 private Models.PropertyModel GetDetails(long propertyid)
 {
     Models.PropertyModel prprty = new Models.PropertyModel();
     CLayer.Property      data   = BLayer.Property.Get(propertyid);
     if (data != null)
     {
         if (data.CheckInTime == "" || data.CheckOutTime == "")
         {
             data.CheckInTime  = "02:00 AM";
             data.CheckOutTime = "12:00 PM";
         }
         string   a             = data.CheckInTime;
         string[] Intime        = a.Split(' ');
         string   Inhrmin       = Intime[0];
         string[] Inhrmin1      = Inhrmin.Split(':');
         string   CheckInclock  = Intime[1];
         string   CheckInHr     = Inhrmin1[0];
         string   CheckInMin    = Inhrmin1[1];
         string   b             = data.CheckOutTime;
         string[] Outtime       = b.Split(' ');
         string   Outhrmin      = Outtime[0];
         string[] Outhrmin1     = Outhrmin.Split(':');
         string   CheckOutclock = Outtime[1];
         string   CheckOutHr    = Outhrmin1[0];
         string   CheckOutMin   = Outhrmin1[1];
         prprty = new Models.PropertyModel()
         {
             PropertyId       = data.PropertyId,
             Title            = data.Title,
             Description      = data.Description,
             Location         = data.Location,
             Status           = (int)data.Status,
             OwnerId          = data.OwnerId,
             Address          = data.Address,
             ZipCode          = data.ZipCode,
             Landmarks        = GetLandmarks(propertyid),
             Pictures         = GetPictures(propertyid),
             Features         = GetFeatures(propertyid),
             Email            = data.Email,
             Accommodations   = GetAccommodations(propertyid),
             DistanceFromCity = data.DistanceFromCity,
             Phone            = data.Phone,
             Mobile           = data.Mobile,
             AgeLimit         = data.AgeLimit,
             CheckInhr        = CheckInHr,
             CheckInmin       = CheckInMin,
             CheckInclock     = CheckInclock,
             CheckOuthr       = CheckOutHr,
             CheckOutmin      = CheckOutMin,
             CheckOutClock    = CheckOutclock,
             PageTitle        = data.PageTitle,
             MetaDescription  = data.MetaDescription,
             PropertyFor      = data.PropertyFor
         };
         prprty.Country = data.Country;
         prprty.State   = data.State;
         if (data.City != null && data.City != "")
         {
             prprty.City = data.City;
         }
         if (data.CityId > 0)
         {
             prprty.City = BLayer.City.Get(data.CityId).Name;
         }
         prprty.CityId = data.CityId;
         prprty.LoadPlaces();
     }
     else
     {
         prprty.PropertyId = -1;
     }
     return(prprty);
 }