예제 #1
0
 public void Delete(StoreLocationView storeLocationModel)
 {
     using (var repo = new StoreLocationRepository())
     {
         var dis = new StoreLocation();
         dis = repo.GetById(storeLocationModel.LocationId);
         repo.Delete(dis);
     }
 }
예제 #2
0
        public ActionResult Edit(StoreLocationView storeLocationModel)
        {
            if (ModelState.IsValid)
            {

                _storeLocation.Update(storeLocationModel);

                return RedirectToAction("Index");

            }
            return View();
        }
예제 #3
0
        public ActionResult Create(StoreLocationView storeLocationModel)
        {
            if (ModelState.IsValid)
            {
                _storeLocation.Insert(storeLocationModel);
                return RedirectToAction("Index");
            }
            else
            {
                ModelState.AddModelError("", "Please Fill In Your Details Correctly");
            }

            return View(storeLocationModel);
        }
예제 #4
0
        public void Insert(StoreLocationView storeLocationModel)
        {
            using (var repo = new StoreLocationRepository())
            {
                var dis = new StoreLocation();
                if (true)
                {
                    dis.LocationId = storeLocationModel.LocationId;
                    dis.Description = storeLocationModel.Description;
                    dis.OpHours = storeLocationModel.OpHours;
                    dis.Address = storeLocationModel.Address;
                    dis.Contact = storeLocationModel.Contact;

                }
                repo.Insert(dis);
            }
        }
예제 #5
0
        public void Update(StoreLocationView storeLocationModel)
        {
            using (var repo = new StoreLocationRepository())
            {
                var dis = new StoreLocation();
                dis = repo.GetById(storeLocationModel.LocationId);
                if (true)
                {

                    dis.Description = storeLocationModel.Description;
                    dis.OpHours = storeLocationModel.OpHours;
                    dis.Address = storeLocationModel.Address;
                    dis.Contact = storeLocationModel.Contact;

                }
                repo.Update(dis);

            }
        }
예제 #6
0
 public ActionResult GetOptometrist(StoreLocationView storeModel,string Description)
 {
     ApplicationDbContext db = new ApplicationDbContext();
     //string Description = "Musgrave Mall";
     int statId;
     string LocationId = db.StorLocations.ToList().Find(x => x.Description == Description).LocationId.ToString();
     List<SelectListItem> optometristNames = new List<SelectListItem>();
     if (!string.IsNullOrEmpty(LocationId))
     {
         statId = Convert.ToInt32(LocationId);
         List<Optometrist> optometrists = db.Optometrists.Where(x => x.LocationId == statId).ToList();
         optometrists.ForEach(x =>
         {
             optometristNames.Add(new SelectListItem { Text = x.OptometristName, Value = x.OptometristName.ToString() });
         });
     }
     return Json(optometristNames, JsonRequestBehavior.AllowGet);
 }
예제 #7
0
        public ActionResult Create(BookingModel bookingModel, string Username, string optometristNames, string Status = "Pending")
        {
            OptometristModel optom = new OptometristModel();
            StoreLocationView sl = new StoreLocationView();
            ApplicationDbContext db = new ApplicationDbContext();

            string user = User.Identity.GetUserName();
            List<Patient> lst = db.Patients.ToList().FindAll(r => r.UserName == user);
            ViewBag.listdetails = lst;

            ViewBag.op = optometristNames;

            if (ModelState.IsValid)
            {
                List<SelectListItem> branchNames = new List<SelectListItem>();

                List<StoreLocation> branch = db.StorLocations.ToList();
                branch.ForEach(x =>
                {
                    branchNames.Add(new SelectListItem { Text = x.Description, Value = x.Description });
                });
                bookingModel.Branch = branchNames;

                if (db.Bookings.Any(p => p.Username == user))
                {
                    ModelState.AddModelError("", "*You have already made a booking, View Booking Details");
                }
                else
                {
                    if (db.Bookings.Any(k => k.BookedDate == bookingModel.BookedDate && db.Bookings.Any(s => s.BookedTime == bookingModel.BookedTime)))
                    {
                        ModelState.AddModelError("", "*Time has already been booked, Please select a new time");

                    }
                    else
                    {

                        foreach (Patient p in lst)
                        {
                            TempData["message"] = string.Format("{0} Please Confirm Your Booking", p.FirstName + " " + p.LastName);
                        }

                        bookingModel.Username = User.Identity.GetUserName();
                        bookingModel.TotalCost = _feeBusiness.CalTot();
                        bookingModel.Status = Status;
                        _bookingBusiness.Insert(bookingModel);
                        return RedirectToAction("Confirm","Booking");
                    }
                }

            }

            else
            {
                List<SelectListItem> branchNames = new List<SelectListItem>();

                List<StoreLocation> branch = db.StorLocations.ToList();
                branch.ForEach(x =>
                {
                    branchNames.Add(new SelectListItem { Text = x.Description, Value = x.Description });
                });
                bookingModel.Branch = branchNames;
                ModelState.AddModelError("", "Please Fill In Your Details Correctly");
            }

            return View(bookingModel);
        }