Ejemplo n.º 1
0
        public async Task <IActionResult> PutPreferences(int id, ApplicationUser applicationUser)
        {
            var userList = _context.ApplicationUsers.Where(u => u.username.Equals(applicationUser.username) && u.Id == id);

            if (!(userList.Count() > 0) || !SecurePasswordHasher.Verify(applicationUser.password, userList.FirstOrDefault().password))
            {
                return(BadRequest());
            }

            var user = userList.FirstOrDefault();

            user.sitePref              = applicationUser.sitePref;
            user.reversePref           = applicationUser.reversePref;
            user.typePref              = applicationUser.typePref;
            user.sortPref              = applicationUser.sortPref;
            _context.Entry(user).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ApplicationUserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
 public ActionResult Edit(Course course)
 {
     db.Entry(course).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Course/" + course.Id));
 }