Esempio n. 1
0
        public void Pause(int Id)
        {
            var repo = new LeaserRepository();
            var user = repo.GetUserId(User.Identity.Name);

            repo.PauseListing(Id, user);
        }
Esempio n. 2
0
        public ActionResult GetUsersListings()
        {
            var repo = new LeaserRepository();
            var Id   = repo.GetUserId(User.Identity.Name);

            return(Json(repo.GetListingsById(Id), JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public void DeletePic(int PicId, string Picture)
        {
            var repo = new LeaserRepository();

            repo.DeletePicturesById(PicId);
            System.IO.File.Delete($"{Server.MapPath("/UploadedImages/")}{Picture}");
        }
Esempio n. 4
0
        public void DeleteItem(int listingId, string UserId)
        {
            var repo = new LeaserRepository();
            var user = repo.GetUserId(User.Identity.Name);

            if (user != UserId)
            {
                return;
            }
            repo.DeleteListing(listingId);
        }
Esempio n. 5
0
        public ActionResult RenewAd(LeasersInformationViewModel listing)
        {
            var repo = new LeaserRepository();

            listing.UserId   = repo.GetUserId(User.Identity.Name);
            listing.Location = new Location {
                Id = listing.LocationId
            };
            var info = listing.ToViewModelSingle <LeasersInformationViewModel, LeasersInformation>();

            repo.RenewAdById(info);
            TempData["Recipient"] = "renew";
            return(RedirectToAction("EmailRecipient", "Home"));
        }
Esempio n. 6
0
        public ActionResult AddRental(LeasersInformationViewModel infoVM)
        {
            var repo = new LeaserRepository();

            infoVM.UserId   = repo.GetUserId(User.Identity.Name);
            infoVM.Location = new Location {
                Id = infoVM.LocationId
            };
            infoVM.Expiration = DateTime.Today.AddMonths(3);
            var info = infoVM.ToViewModelSingle <LeasersInformationViewModel, LeasersInformation>();

            repo.AddHouse(info);
            TempData["Recipient"] = "add";
            return(RedirectToAction("EmailRecipient", "Home"));
        }
Esempio n. 7
0
        public ActionResult UploadImage(HttpPostedFileBase imageFile, int Id)
        {
            string fileName = Guid.NewGuid() + Path.GetExtension(imageFile.FileName);

            imageFile.SaveAs($"{Server.MapPath("/UploadedImages/")}{fileName}");

            var repo = new LeaserRepository();

            var picLimit = repo.AmountOfPicturesById(Id);

            if (picLimit >= 10)
            {
                TempData["PictureLimit"] = "Limited to 10 pictures only";
                return(RedirectToAction("UsersListings"));
            }

            repo.UploadImage(fileName, Id);
            return(RedirectToAction("UsersListings"));
        }
Esempio n. 8
0
        public void Update(LeasersInformationViewModel listing)
        {
            var repo = new LeaserRepository();

            listing.UserId   = repo.GetUserId(User.Identity.Name);
            listing.Location = new Location {
                Id = listing.LocationId
            };
            var hello = listing;

            if (listing.ContactInfo == null)
            {
                return;
            }
            var info = listing.ToViewModelSingle <LeasersInformationViewModel, LeasersInformation>();

            repo.Update(info);
            repo.SaveChanges();
        }
Esempio n. 9
0
        public ActionResult GetLocations()
        {
            var repo = new LeaserRepository();

            return(Json(repo.GetAllLocations(), JsonRequestBehavior.AllowGet));
        }
Esempio n. 10
0
        public ActionResult GetPictures(int PicId)
        {
            var repo = new LeaserRepository();

            return(Json(repo.GetPicturesById(PicId), JsonRequestBehavior.AllowGet));
        }