Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            WebSenateModels webSenateModels = db.WebSenateModels.Find(id);

            db.WebSenateModels.Remove(webSenateModels);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Id,SenateName,Enabled,Load,Acases")] WebSenateModels webSenateModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(webSenateModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(webSenateModels));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// <c>Edit</c> (GET) - "webová" metoda pro změnu vybraného senátu.
        /// </summary>
        /// <remarks>Models: WeSenateModels.cs, Views: WebSenate/Edit.cshtml.</remarks>
        // GET: WebSenate/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WebSenateModels webSenateModels = db.WebSenateModels.Find(id);

            if (webSenateModels == null)
            {
                return(HttpNotFound());
            }
            return(View(webSenateModels));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "SenateName,Enabled,Load,Acases")] WebSenateModels webSenateModels)
        {
            /* if (webSenateModels == null)
             * {
             *  throw new ArgumentNullException(nameof(webSenateModels));
             * } */

            if (ModelState.IsValid)
            {
                //webSenateModels.SenateCreator_Id = UserID(); // cizí klíč v DB
                string          currentUserId = User.Identity.GetUserId();
                ApplicationUser currentUser   = db.Users.FirstOrDefault(x => x.Id == currentUserId);
                webSenateModels.SenateUserSet(currentUser); // cizí klíč v DB
                db.WebSenateModels.Add(webSenateModels);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(webSenateModels));
        }