Exemplo n.º 1
0
 public ActionResult DeleteConfirmed(int id)
 {
     Cleanings cleanings = db.Cleanings.Find(id);
     db.Cleanings.Remove(cleanings);
     db.SaveChanges();
     return RedirectToAction("Index");
 }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "EmployeeId,PavilionId,CleaningDate,TimeForCleaning")] Cleanings cleanings)
        {
            ViewBag.Exception = null;
            string msg = null;
            if (ModelState.IsValid)
            {
                db.Cleanings.Add(cleanings);
                try
                {
                    db.SaveChanges();

                }
                catch (Exception e)
                {

                    msg = e.InnerException.InnerException.Message;

                    ViewBag.Exception = msg;
                    ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "FirstName");
                    ViewBag.PavilionId = new SelectList(db.Pavilions, "PavilionId", "Name");

                    return View(cleanings);

                }
                return RedirectToAction("Index");
            }

            ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "FirstName", cleanings.EmployeeId);
            ViewBag.PavilionId = new SelectList(db.Pavilions, "PavilionId", "Name", cleanings.PavilionId);
            return View(cleanings);
        }
Exemplo n.º 3
0
 // GET: Cleanings/Details/5
 public ActionResult Details(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     Cleanings cleanings = db.Cleanings.Find(id);
     if (cleanings == null)
     {
         return HttpNotFound();
     }
     return View(cleanings);
 }
Exemplo n.º 4
0
 // GET: Cleanings/Edit/5
 public ActionResult Edit(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     Cleanings cleanings = db.Cleanings.Find(id);
     if (cleanings == null)
     {
         return HttpNotFound();
     }
     ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "FirstName", cleanings.EmployeeId);
     ViewBag.PavilionId = new SelectList(db.Pavilions, "PavilionId", "Name", cleanings.PavilionId);
     return View(cleanings);
 }
Exemplo n.º 5
0
        public ActionResult Edit([Bind(Include = "CleaningId,EmployeeId,PavilionId,CleaningDate,TimeForCleaning,RowVersion")] Cleanings cleanings)
        {
            ViewBag.Exception = null;
            string msg = null;

            if (ModelState.IsValid)
            {
                var entity = db.Cleanings.Single(p => p.CleaningId == cleanings.CleaningId);

                if (entity.RowVersion != cleanings.RowVersion)
                {
                    TempData["Exception"] = "Entity was modified by another user. Check values and perform edit action again";
                    return RedirectToAction("Edit");
                }

                entity.RowVersion++;
                entity.EmployeeId = cleanings.EmployeeId;
                entity.PavilionId = cleanings.PavilionId;
                entity.CleaningDate = cleanings.CleaningDate;
                entity.TimeForCleaning = cleanings.TimeForCleaning;

                db.Entry(entity).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();

                }
                catch (Exception e)
                {
                    if (e.InnerException == null)
                    {
                        msg = e.Message;
                    }
                    else
                        msg = e.InnerException.InnerException.Message;

                    ViewBag.Exception = msg;

                    return View(cleanings);

                }
                return RedirectToAction("Index");
            }
            ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "FirstName", cleanings.EmployeeId);
            ViewBag.PavilionId = new SelectList(db.Pavilions, "PavilionId", "Name", cleanings.PavilionId);
            return View(cleanings);
        }