public ActionResult Create(DoctorTimeSlotTable doctorTimeSlotTable)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"])))
            {
                return(RedirectToAction("Login", "Home"));
            }
            var doc = (DoctorTable)Session["Doctor"];

            doctorTimeSlotTable.DoctorID = doc.DoctorID;
            if (ModelState.IsValid)
            {
                var find = db.DoctorTimeSlotTables.Where(t => t.DoctorID == doc.DoctorID && t.FromTime == doctorTimeSlotTable.FromTime && t.ToTime == doctorTimeSlotTable.ToTime).FirstOrDefault();
                if (find == null)
                {
                    db.DoctorTimeSlotTables.Add(doctorTimeSlotTable);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.Message = "Already exist time";
                }
            }

            return(View(doctorTimeSlotTable));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"])))
            {
                return(RedirectToAction("Login", "Home"));
            }
            DoctorTimeSlotTable doctorTimeSlotTable = db.DoctorTimeSlotTables.Find(id);

            db.DoctorTimeSlotTables.Remove(doctorTimeSlotTable);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: DoctorTimeSlotTables/Edit/5
        public ActionResult Edit(int?id)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"])))
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DoctorTimeSlotTable doctorTimeSlotTable = db.DoctorTimeSlotTables.Find(id);

            if (doctorTimeSlotTable == null)
            {
                return(HttpNotFound());
            }
            return(View(doctorTimeSlotTable));
        }
Ejemplo n.º 4
0
        public ActionResult Edit(DoctorTimeSlotTable doctorTimeSlotTable)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"])))
            {
                return(RedirectToAction("Login", "Home"));
            }

            if (ModelState.IsValid)
            {
                var find = db.DoctorTimeSlotTables.Where(d => d.DoctorID == d.DoctorID && d.FromTime == doctorTimeSlotTable.FromTime && d.ToTime == doctorTimeSlotTable.ToTime && d.DoctorTimeSlotID != doctorTimeSlotTable.DoctorTimeSlotID).FirstOrDefault();
                if (find == null)
                {
                    db.Entry(doctorTimeSlotTable).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.Message = "Already in List Please Check Status";
                }
            }
            return(View(doctorTimeSlotTable));
        }