Ejemplo n.º 1
0
        public ActionResult Create(EventCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(model.Other))
                    model.EventItem.Event = model.Other;
                var user = db.Users.Find(User.Identity.GetUserId());
                user.EventsList.Add(model.EventItem);
                db.SaveChanges();

                return RedirectToAction("Index");
            }

            return View(model);
        }
Ejemplo n.º 2
0
 // GET: /Events/Edit/5
 public ActionResult Edit(int? id)
 {
     if (id == null)
     {
         return RedirectToAction("Index", "Events");//new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     Events events = db.Events.Find(id);
     if (events == null)
     {
         return RedirectToAction("Index", "Events");//HttpNotFound();
     }
     var model = new EventCreateViewModel();
     model.EventItem = events;
     if (model.Subjects.Find(x => x.Text.Equals(model.EventItem.Event)) == null)
     {
         model.Other = model.EventItem.Event;
         model.EventItem.Event = "אחר";
     }
     return View(model);
 }
Ejemplo n.º 3
0
        // GET: /Events/Create
        public ActionResult Create()
        {
            var model = new EventCreateViewModel();

            return View(model);
        }
Ejemplo n.º 4
0
 public ActionResult Edit(EventCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (!string.IsNullOrEmpty(model.Other))
             model.EventItem.Event = model.Other;
         db.Entry(model.EventItem).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(model);
 }