Exemple #1
0
        public async Task <IActionResult> Create(DateTime date)
        {
            ViewBag.anotherDate = "סמן תאריך נוסף כתפוס";
            if (ModelState.IsValid)
            {
                ApartmentAvailability apartmentAvailability = new ApartmentAvailability();
                apartmentAvailability.Apartment = _context.Apartment.Where(u => u.Id == (int)TempData["Availability"]).FirstOrDefault();
                var result = from a in _context.ApartmentAvailability
                             where (a.Apartment.Equals(apartmentAvailability.Apartment)) && (a.Availability.NotAvailable.Equals(date))
                             select a;

                if (result.ToList().Count() > 0)
                {
                    ViewBag.errorTime = "*התאריך שבחרת כבר סומן כתפוס";
                }
                else if (date.CompareTo(DateTime.Now.AddMonths(3)) > 0)
                {
                    ViewBag.errorTime = "*יש להזין תאריכים בתווך של 3 חודשים מהיום";
                }
                else
                {
                    ViewBag.errorTime = "*התאריך הוזן במערכת, ניתן לסמן תאריך נוסף";
                    apartmentAvailability.Availability   = _context.Availability.Where(a => a.NotAvailable.Equals(date)).FirstOrDefault();;
                    apartmentAvailability.AvailabilityId = apartmentAvailability.Availability.Id;
                    apartmentAvailability.ApartmentId    = (int)TempData["Availability"];
                    _context.Add(apartmentAvailability);
                    await _context.SaveChangesAsync();
                }

                TempData["Availability"] = TempData["Availability"];
            }

            //ViewData["AvailabilityId"] = new SelectList(_context.Availability, "Id", "Id", apartmentAvailability.AvailabilityId);
            return(View());
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("Id,Address,City,x,y")] Location location)
        {
            if (ModelState.IsValid)
            {
                _context.Add(location);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "ApartmentAmenities"));
            }
            return(View(location));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("Id,NumOfRooms,NumOfPersons,Description,Parking,Wifi,Accessibility,AirConditioning,Balcony,Comment")] ApartmentAmenities apartmentAmenities)
        {
            if (ModelState.IsValid)
            {
                _context.Add(apartmentAmenities);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "Policies"));
            }
            return(View(apartmentAmenities));
        }
Exemple #4
0
        public async Task <IActionResult> Create([Bind("Id,NotAvailable")] Availability availability)
        {
            if (ModelState.IsValid)
            {
                _context.Add(availability);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(availability));
        }
Exemple #5
0
        public async Task <IActionResult> Create([Bind("OrderPaymentId,CC_Number,CC_Exp,CC_CVV")] OrderPayment orderPayment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderPayment);
                await _context.SaveChangesAsync();

                int orderId = HttpContext.Session.GetInt32("OrderId").Value;
                HttpContext.Session.Remove("OrderId");
                var dbOrder = _context.Order.Find(orderId);
                dbOrder.PaymentId = orderPayment.OrderPaymentId;
                await _context.SaveChangesAsync();

                return(RedirectToAction("Success", "Orders"));
            }
            return(View(orderPayment));
        }
        public async Task <IActionResult> Create([Bind("Id,PriceAdult,PriceChild")] Apartment apartment)
        {
            if (ModelState.IsValid)
            {
                apartment.Renter    = _context.Renter.OrderByDescending(u => u.Id).FirstOrDefault();
                apartment.Location  = _context.Location.OrderByDescending(u => u.Id).FirstOrDefault();
                apartment.Amenities = _context.ApartmentAmenities.OrderByDescending(u => u.Id).FirstOrDefault();
                apartment.Policy    = _context.Policy.OrderByDescending(u => u.Id).FirstOrDefault();
                apartment.Image     = _context.Image.OrderByDescending(u => u.Id).FirstOrDefault();


                _context.Add(apartment);
                await _context.SaveChangesAsync();

                TempData["Availability"] = apartment.Id;
                return(RedirectToAction("Create", "ApartmentAvailabilities"));
            }
            ViewBag.Success = false;
            return(View(apartment));
        }
Exemple #7
0
        public async Task <IActionResult> Create([Bind("Id,password,FirstName,LastName,Phone,Mail,Username")] User user)
        {
            if (ModelState.IsValid)
            {
                var result = from u in _context.User
                             where u.Username == user.Username
                             select u;
                var tempUser = result.FirstOrDefault();
                if (tempUser != null)
                {
                    ViewBag.error = "שם משתמש זה כבר קיים במערכת";
                    return(View());
                }
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Home", "Apartments"));
            }
            return(View(user));
        }
Exemple #8
0
        public async Task <IActionResult> Create([Bind("Id,password,FirstName,LastName,Phone,Mail,Username")] Renter renter)
        {
            if (ModelState.IsValid)
            {
                var result = from u in _context.Renter
                             where u.Username == renter.Username
                             select u;
                var list = result.ToList();
                if (list.Count() > 0)
                {
                    ViewBag.error = "שם משתמש זה כבר קיים במערכת";
                    return(View());
                }
                _context.Add(renter);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "Locations"));
            }
            return(View(renter));
        }
Exemple #9
0
        public async Task <IActionResult> Create([Bind("Id,ApartmentId,QuantityAdult,QuantityChild,CheckIn,CheckOut")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                var days   = GetStayDays(order.CheckIn, order.CheckOut);
                var naDays = days.Select(item => new ApartmentAvailability()
                {
                    ApartmentId = order.ApartmentId, Availability = new Availability()
                    {
                        NotAvailable = item
                    }
                });
                _context.ApartmentAvailability.AddRange(naDays);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Create", "OrderPayments", routeValues: new { orderId = order.Id }));
            }
            return(View(order));
        }
        [HttpPost] //Postback

        public async Task <IActionResult> Upload_Image(IFormFile file1, IFormFile file2, IFormFile file3, IFormFile file4)

        {
            //--------< Upload_ImageFile() >--------

            //< check >

            if (file1 == null || file1.Length == 0)
            {
                return(Content("לא נבחר קובץ"));
            }
            if (file2 == null || file2.Length == 0)
            {
                return(Content("לא נבחר קובץ"));
            }
            if (file3 == null || file3.Length == 0)
            {
                return(Content("לא נבחר קובץ"));
            }
            if (file4 == null || file4.Length == 0)
            {
                return(Content("לא נבחר קובץ"));
            }

            //</ check >



            //< get Path >

            string path_Root = _appEnvironment.WebRootPath;

            string path_to_Images1 = path_Root + "\\User_Files\\Images\\" + file1.FileName;
            string path_to_Images2 = path_Root + "\\User_Files\\Images\\" + file2.FileName;
            string path_to_Images3 = path_Root + "\\User_Files\\Images\\" + file3.FileName;
            string path_to_Images4 = path_Root + "\\User_Files\\Images\\" + file4.FileName;

            //</ get Path >



            //< Copy File to Target >

            using (var stream = new FileStream(path_to_Images1, FileMode.Create))
            {
                await file1.CopyToAsync(stream);
            }
            using (var stream = new FileStream(path_to_Images2, FileMode.Create))
            {
                await file2.CopyToAsync(stream);
            }
            using (var stream = new FileStream(path_to_Images3, FileMode.Create))
            {
                await file3.CopyToAsync(stream);
            }
            using (var stream = new FileStream(path_to_Images4, FileMode.Create))
            {
                await file4.CopyToAsync(stream);
            }

            //</ Copy File to Target >



            //< output >
            Image image = new Image();

            image.BedRoom    = "/User_Files/Images/" + Path.GetFileName(file1.FileName);
            image.DiningRoom = "/User_Files/Images/" + Path.GetFileName(file2.FileName);
            image.Ketchen    = "/User_Files/Images/" + Path.GetFileName(file3.FileName);
            image.LivingRoom = "/User_Files/Images/" + Path.GetFileName(file4.FileName);



            _context.Add(image);
            await _context.SaveChangesAsync();


            return(RedirectToAction("Create", "Apartments"));

            //</ output >

            //--------</ Upload_ImageFile() >--------
        }