Ejemplo n.º 1
0
 public ActionResult Create(UserModel user)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _repository.InsertUser(user);
             return RedirectToAction("Index2");
         }
     }
     catch (Exception e)
     {
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return View(user);
 }
Ejemplo n.º 2
0
 public void UpdateUser(UserModel user)
 {
     Table userData = _dataContext.Tables.Where(u => u.Id == user.Id).SingleOrDefault();
     userData.Topic = user.topic;
     userData.Description = user.Description;
     userData.checkbox = (user.chkbx).ToString();
     userData.status = (user.status).ToString();
     userData.uname = user.usname;
     _dataContext.SubmitChanges();
 }
Ejemplo n.º 3
0
 public void InsertUser(UserModel user)
 {
     var userData = new Table()
     {
         Topic = user.topic,
         Description=user.Description,
         checkbox = (user.chkbx).ToString()
     };
     _dataContext.Tables.InsertOnSubmit(userData);
     _dataContext.SubmitChanges();
 }
Ejemplo n.º 4
0
        public UserModel GetUserById(int Id)
        {
            var query = from u in _dataContext.Tables
                        where u.Id == Id
                        select u;
            var user = query.FirstOrDefault();
            var model = new UserModel()
            {

                topic = user.Topic,
                Description=user.Description,
                chkbx = Convert.ToBoolean(user.checkbox),
                status = Convert.ToBoolean(user.status)
            };
            return model;
        }