예제 #1
0
        public async Task UpdateViewFilterAsync(ViewFilter filter)
        {
            var userManager = _owin.Get<ApplicationUserManager>();
            var user = _dbContext.Users.Single(u => u.Email == _owin.Authentication.User.Identity.Name);
            if (user.ViewFilter == null)
            {
                user.ViewFilter = _dbContext.ViewFilters.Create();
                _dbContext.ViewFilters.Add(user.ViewFilter);
            }

            user.ViewFilter.AnimalTypes = filter.AnimalTypes;
            user.ViewFilter.OnlyFollowing = filter.OnlyFollowing;

            await _dbContext.SaveChangesAsync();
        }
예제 #2
0
 public async Task<ActionResult> ViewFilter(ViewFilterModel model)
 {
     var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
     var viewFilter = new ViewFilter()
     {
         AnimalTypes =
           (model.Equine ? AnimalTypes.Equine : AnimalTypes.None)
         | (model.Canine ? AnimalTypes.Canine : AnimalTypes.None)
         | (model.Feline ? AnimalTypes.Feline : AnimalTypes.None),
         OnlyFollowing = model.OnlyFollowing
     };
     await _userService.UpdateViewFilterAsync(viewFilter);
     return Redirect("/");
 }