Ejemplo n.º 1
0
        public ActionResult Save(Personal personal)
        {
            if (!ModelState.IsValid)
            {
                var model = new PersonalFormViewModel()
                {
                    Departments = db.Department1.ToList(),
                    Personal    = personal
                };
                return(View("PersonalForm", model));
            }
            MessageViewModel modelMessage = new MessageViewModel();

            if (personal.Id == 0)
            {
                db.Personal.Add(personal);
                modelMessage.Message = personal.Name + " " + personal.Surname + " added. Press to return ";
            }
            else
            {
                db.Entry(personal).State = System.Data.Entity.EntityState.Modified;
                modelMessage.Message     = "Data of " + personal.Name + " " + personal.Surname + " updated. Press to return ";
            }
            db.SaveChanges();
            modelMessage.Status   = true;
            modelMessage.LinkText = "Personal List";
            modelMessage.Url      = "/Personal";
            return(View("_Message", modelMessage));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Id,Name,Password,Role")] User1 user1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user1));
 }