public ProfilesController(ProfilesService service, BlogsService blogsService, CommentsService commentsService, AccountsService acctsService)
 {
     _service        = service;
     _blogService    = blogsService;
     _commentService = commentsService;
     _acctService    = acctsService;
 }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var startingIndex = model.Email.IndexOf("@");
                var userName      = model.Email.Remove(startingIndex);
                var user          = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    UserManager.AddToRole(user.Id, "Customer");
                    var createProfile = new ProfilesService(Guid.Parse(user.Id));
                    createProfile.Create();
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
                    //Assign Role to user Here
                    //Ends Here
                    return(RedirectToAction("Index", "Home"));
                }
                //ViewBag.Name = new SelectList(context.Roles.Where(u => !u.Name.Contains("Admin")).ToList(), "Name", "Name");

                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #3
0
        public CoinbaseProClient(
            IAuthenticator authenticator,
            IHttpClient httpClient,
            bool sandBox = false)
        {
            var clock = new Clock();
            var httpRequestMessageService = new HttpRequestMessageService(authenticator, clock, sandBox);
            var createWebSocketFeed       = (Func <IWebSocketFeed>)(() => new WebSocketFeed(sandBox));
            var queryBuilder = new QueryBuilder();

            AccountsService              = new AccountsService(httpClient, httpRequestMessageService);
            CoinbaseAccountsService      = new CoinbaseAccountsService(httpClient, httpRequestMessageService);
            OrdersService                = new OrdersService(httpClient, httpRequestMessageService, queryBuilder);
            PaymentsService              = new PaymentsService(httpClient, httpRequestMessageService);
            WithdrawalsService           = new WithdrawalsService(httpClient, httpRequestMessageService);
            DepositsService              = new DepositsService(httpClient, httpRequestMessageService);
            ProductsService              = new ProductsService(httpClient, httpRequestMessageService, queryBuilder);
            CurrenciesService            = new CurrenciesService(httpClient, httpRequestMessageService);
            FillsService                 = new FillsService(httpClient, httpRequestMessageService);
            FundingsService              = new FundingsService(httpClient, httpRequestMessageService, queryBuilder);
            ReportsService               = new ReportsService(httpClient, httpRequestMessageService);
            UserAccountService           = new UserAccountService(httpClient, httpRequestMessageService);
            StablecoinConversionsService = new StablecoinConversionsService(httpClient, httpRequestMessageService);
            FeesService     = new FeesService(httpClient, httpRequestMessageService);
            ProfilesService = new ProfilesService(httpClient, httpRequestMessageService);
            WebSocket       = new WebSocket.WebSocket(createWebSocketFeed, authenticator, clock);

            Log.Information("CoinbaseProClient constructed");
        }
Example #4
0
        public async Task RemoveFollowerAsync_WithValidData_ShouldRemoveFollowerFromDatabase()
        {
            // Arrange
            this.InitilaizeMapper();
            var context                = InMemoryDbContext.Initiliaze();
            var userRepository         = new EfDeletableEntityRepository <ApplicationUser>(context);
            var userFollowerRepository = new EfRepository <UserFollower>(context);
            var profileService         = new ProfilesService(userRepository, userFollowerRepository);

            await this.SeedUsers(context);

            await userFollowerRepository.AddAsync(new UserFollower { UserId = "userOneId", FollowerId = "userTwoId" });

            await userFollowerRepository.SaveChangesAsync();

            var model = new AddFollowerModel
            {
                UserId     = "userOneId",
                FollowerId = "userTwoId",
            };

            // Act
            int expectedCount = userFollowerRepository.All().Count() - 1;
            await profileService.RemoveFollowerAsync(model);

            int actualCount = userFollowerRepository.All().Count();

            // Assert
            Assert.Equal(expectedCount, actualCount);
        }
        public IHttpActionResult GetUserProfile()
        {
            try
            {
                profilesService = new ProfilesService(User.Identity.Name);
            }
            catch (UserNotFoundException)
            {
                return(NotFound());
            }

            UserProfile userProfile = profilesService.Get();

            UserProfileDTO userProfileDTO = new UserProfileDTO()
            {
                FirstName   = userProfile.FirstName,
                LastName    = userProfile.LastName,
                PhotoURL    = userProfile.PhotoURL,
                Email       = userProfile.Email,
                PhoneNumber = userProfile.PhoneNumber,
                Country     = userProfile.Country,
                City        = userProfile.City,
                Address     = userProfile.Address
            };

            return(Ok(userProfileDTO));
        }
Example #6
0
        public async Task GetFollowerRequestsAsync_WithValidUserId_ShouldReturnFollowerRequests()
        {
            // Arrange
            this.InitilaizeMapper();
            var context                = InMemoryDbContext.Initiliaze();
            var userRepository         = new EfDeletableEntityRepository <ApplicationUser>(context);
            var userFollowerRepository = new EfRepository <UserFollower>(context);
            var profileService         = new ProfilesService(userRepository, userFollowerRepository);

            await this.SeedUsers(context);

            await userFollowerRepository.AddAsync(new UserFollower
                                                  { UserId = "userOneId", FollowerId = "userTwoId", IsApproved = false });

            await userFollowerRepository.SaveChangesAsync();

            // Act
            var requests = await profileService.GetFollowerRequestsAsync("userOneId");

            string expectedUsername = "******"; // The username of the follower.
            string actualUsername   = requests.FirstOrDefault().FollowerUserName;

            // Assert
            Assert.Equal(expectedUsername, actualUsername);
        }
Example #7
0
        public void ShouldReturnName()
        {
            var mockRepoImage = new Mock <IDeletableEntityRepository <Image> >();
            var listPet       = new List <Pet>();
            var mockRepoPet   = new Mock <IDeletableEntityRepository <Pet> >();

            mockRepoPet.Setup(x => x.AllAsNoTracking()).Returns(listPet.AsQueryable());
            mockRepoPet.Setup(x => x.AddAsync(It.IsAny <Pet>()));
            mockRepoPet.Setup(x => x.Delete(It.IsAny <Pet>()));
            var mockRepoUser = new Mock <IDeletableEntityRepository <ApplicationUser> >();
            var service      = new ProfilesService(mockRepoPet.Object, mockRepoUser.Object, mockRepoImage.Object);

            var pet = new Pet
            {
                BreedId       = 1,
                CityId        = 1,
                Id            = 1,
                Name          = "GoshoCat",
                DateOfBirth   = new DateTime(2008, 3, 1, 7, 0, 0),
                SpecieId      = 1,
                AddedByUserId = "PeshoId",
            };

            listPet.Add(pet);
            var actualName = service.GetName(1);

            Assert.Equal("GoshoCat", actualName);
        }
Example #8
0
 public ProfilesController(ProfilesService profilesService, UserManager <IdentityUser> userManager, IJwtTokenService tokenService, SignInManager <IdentityUser> signInManager)
 {
     this.profilesService = profilesService;
     this.userManager     = userManager;
     this.tokenService    = tokenService;
     this.signInManager   = signInManager;
 }
Example #9
0
        public async System.Threading.Tasks.Task GetAllShouldReturnAllRecipesFromUserAsync()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            AutoMapperConfig.RegisterMappings(Assembly.Load("CookingBook.Web.ViewModels"));
            var dbContext  = new ApplicationDbContext(options);
            var userRepo   = new EfDeletableEntityRepository <ApplicationUser>(dbContext);
            var recipeRepo = new EfDeletableEntityRepository <Recipe>(dbContext);
            var service    = new ProfilesService(recipeRepo, userRepo);
            await dbContext.Users.AddAsync(new ApplicationUser
            {
                Name               = "Trayan Keranov",
                Id                 = "trk",
                UserName           = "******",
                NormalizedUserName = "******",
                Email              = "*****@*****.**",
                NormalizedEmail    = "*****@*****.**",
                PasswordHash       = "AQAAAAEAACcQAAAAEKDTOW0hiJThqFCz2cTS+wMBN2HthJkHT1jCsqVhgYwc0XikiVo0ESJYcqs8yrZkgg==",
                SecurityStamp      = "5ZMAFTFQEDOZPXC573KIOV5B56KVMHKS",
                ConcurrencyStamp   = "5ed4afbd-318e-456b-8d1b-19a36f2d82f1",
                CreatedOn          = DateTime.Parse("1993-03-21 08:10:00.2228617"),
                EmailConfirmed     = true,
                Roles              = new List <IdentityUserRole <string> >(),
            });

            await dbContext.Recipes.AddAsync(new Recipe { Id = "first", UserId = "trk", Title = "firstTitle", });

            await dbContext.Recipes.AddAsync(new Recipe { Id = "second", UserId = "trk", Title = "secondTitle", });

            await dbContext.SaveChangesAsync();

            Assert.Equal(2, service.GetByUserId <RecipeByUserViewModel>("trk").Count());
            Assert.Empty(service.GetByUserId <RecipeByUserViewModel>("sdfghhjkjhgf"));
        }
Example #10
0
        public async Task DeleteAsyncPhoto()
        {
            var listImage     = new List <Image>();
            var mockRepoImage = new Mock <IDeletableEntityRepository <Image> >();

            mockRepoImage.Setup(x => x.All()).Returns(listImage.AsQueryable());
            mockRepoImage.Setup(x => x.Delete(It.IsAny <Image>()))
            .Callback(
                (Image image) => listImage.Remove(image));

            var mockRepoPet = new Mock <IDeletableEntityRepository <Pet> >();

            var mockRepoUser = new Mock <IDeletableEntityRepository <ApplicationUser> >();

            var service = new ProfilesService(mockRepoPet.Object, mockRepoUser.Object, mockRepoImage.Object);

            var image = new Image
            {
                AddedByUserId = "PeshoId",
                Id            = "ImageId",
                PetId         = 1,
                Url           = "vasko.com",
            };

            listImage.Add(image);
            await service.DeleteAsyncPhoto("ImageId", "PeshoId");

            Assert.Empty(listImage);
        }
Example #11
0
        public ActionResult Edit(ProfileEdit model)
        {
            var userId = Guid.Parse(User.Identity.GetUserId());

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.UserID != userId.ToString())
            {
                ModelState.AddModelError("", "IDMismatch");
                return(View(model));
            }

            var service = new ProfilesService(userId);

            if (service.UpdateProfile(model))
            {
                TempData["SaveResult"] = "Your Profile has been updated!";
                return(RedirectToAction("Details", new { id = userId }));
            }
            ModelState.AddModelError("", "Your Profile could not be updated.");
            return(View(model));
        }
Example #12
0
        public void IsUserDetailsPageShouldReturnFalse()
        {
            var userChars = new List <UserCharacteristic>();

            var mockUserChar = new Mock <IDeletableEntityRepository <UserCharacteristic> >();

            mockUserChar.Setup(x => x.All()).Returns(userChars.AsQueryable());
            mockUserChar.Setup(x => x.AddAsync(It.IsAny <UserCharacteristic>())).Callback((UserCharacteristic uc) => userChars.Add(uc));

            var service = new ProfilesService(mockUserChar.Object, null);

            var user = new UserCharacteristic
            {
                Id     = "1",
                UserId = "1",
            };
            var secondUser = new UserCharacteristic
            {
                Id     = "1",
                UserId = "2",
            };

            userChars.Add(user);
            userChars.Add(secondUser);

            bool result = service.IsUserDetailsPage("1", "2");

            Assert.Equal(false, result);
        }
Example #13
0
        public void EditViewShouldWorkCorrectly()
        {
            var userChars = new List <UserCharacteristic>();

            var mockUserChar = new Mock <IDeletableEntityRepository <UserCharacteristic> >();

            mockUserChar.Setup(x => x.All()).Returns(userChars.AsQueryable());
            mockUserChar.Setup(x => x.AddAsync(It.IsAny <UserCharacteristic>())).Callback((UserCharacteristic uc) => userChars.Add(uc));

            var service = new ProfilesService(mockUserChar.Object, null);

            var user = new UserCharacteristic
            {
                Id        = "1",
                UserId    = "1",
                FirstName = "Todor",
                LastName  = "Georgiev",
            };

            userChars.Add(user);

            var usr = service.EditView <ProfileViewModel>("1");

            Assert.Equal(user.FirstName, usr.FirstName);
            Assert.Equal(user.LastName, usr.LastName);
        }
Example #14
0
 public ProfilesController(ProfilesService ps, KeepsService ks, VaultsService vs, VaultKeepsService vks)
 {
     _ps  = ps;
     _ks  = ks;
     _vs  = vs;
     _vks = vks;
 }
        private ProfilesService CreateProfileService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new ProfilesService(userId);

            return(service);
        }
Example #16
0
 public ProfilesController(ProfilesService profilesService, KeepsService keepsService, VaultsService vaultsService, VaultKeepsService vaultKeepsService)
 {
     _profilesService   = profilesService;
     _keepsService      = keepsService;
     _vaultsService     = vaultsService;
     _vaultKeepsService = vaultKeepsService;
 }
Example #17
0
        public void GetAllShouldReturnCount2()
        {
            var userChars = new List <UserCharacteristic>();

            var mockUserChar = new Mock <IDeletableEntityRepository <UserCharacteristic> >();

            mockUserChar.Setup(x => x.All()).Returns(userChars.AsQueryable());
            mockUserChar.Setup(x => x.AddAsync(It.IsAny <UserCharacteristic>())).Callback((UserCharacteristic uc) => userChars.Add(uc));

            var service = new ProfilesService(mockUserChar.Object, null);

            var user = new UserCharacteristic
            {
                Id     = "1",
                UserId = "1",
            };
            var secondUser = new UserCharacteristic
            {
                Id     = "1",
                UserId = "2",
            };

            userChars.Add(user);
            userChars.Add(secondUser);

            var users          = service.GetAll <ProfileViewModel>();
            var expectedResult = 2;

            Assert.Equal(expectedResult, users.Count());
        }
Example #18
0
 private void ContentDialog_Opened(ContentDialog sender, ContentDialogOpenedEventArgs args)
 {
     _profilesService = ProfilesService.Instance;
     if (_profilesService.ExistProfile(Ssid))
     {
         ReplaceWarningTextBlock.Visibility = Visibility.Visible;
     }
 }
Example #19
0
        internal void Initialize()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString());

            this.dbContext  = new ApplicationDbContext(options.Options);
            this.repository = new EfDeletableEntityRepository <ApplicationUser>(this.dbContext);
            this.service    = new ProfilesService(this.repository);
        }
Example #20
0
        public async Task EditPersonalDetailsShouldWorkCorrectly()
        {
            var userChars = new List <UserCharacteristic>();

            var mockUserChar = new Mock <IDeletableEntityRepository <UserCharacteristic> >();

            mockUserChar.Setup(x => x.All()).Returns(userChars.AsQueryable());
            mockUserChar.Setup(x => x.AddAsync(It.IsAny <UserCharacteristic>())).Callback((UserCharacteristic uc) => userChars.Add(uc));

            var service = new ProfilesService(mockUserChar.Object, null);

            var userChar = new UserCharacteristic
            {
                Id                     = "1",
                FirstName              = "Todor",
                LastName               = "Georgiev",
                Weight                 = 100,
                Height                 = 100,
                Description            = "xaxa",
                UserId                 = "1",
                City                   = City.Burgas,
                Gender                 = Gender.Male,
                EyeColor               = EyesColor.Blue,
                HairColor              = HairColor.Black,
                WeddingStatus          = WeddingStatus.Single,
                WhatAreYouSearchingFor = WhatAreYouSearchingFor.Date,
            };

            userChars.Add(userChar);
            await service.EditPersonalDetails(new Web.ViewModels.Profiles.EditDetailsViewModel
            {
                Id                     = "1",
                FirstName              = "Simona",
                LastName               = "Kasabova",
                Weight                 = 150,
                Height                 = 150,
                Description            = "az",
                UserId                 = "1",
                City                   = City.Dobrich,
                Gender                 = Gender.Female,
                EyeColor               = EyesColor.Brown,
                HairColor              = HairColor.Red,
                WeddingStatus          = WeddingStatus.Married,
                WhatAreYouSearchingFor = WhatAreYouSearchingFor.Flirt,
            });

            Assert.Equal("Simona", userChar.FirstName);
            Assert.Equal("Kasabova", userChar.LastName);
            Assert.Equal(150, userChar.Weight);
            Assert.Equal(150, userChar.Height);
            Assert.Equal(City.Dobrich, userChar.City);
            Assert.Equal(Gender.Female, userChar.Gender);
            Assert.Equal(EyesColor.Brown, userChar.EyeColor);
            Assert.Equal(HairColor.Red, userChar.HairColor);
            Assert.Equal(WeddingStatus.Married, userChar.WeddingStatus);
            Assert.Equal(WhatAreYouSearchingFor.Flirt, userChar.WhatAreYouSearchingFor);
        }
Example #21
0
        private void ProfileRenamed(object sender, EventArgs <IProfileUserControl> e)
        {
            SelectedProfile.ProfileName   = e.Value.ProfileName;
            SelectedProfile.Prefix        = e.Value.Prefix;
            SelectedProfile.AdminUsername = e.Value.AdminUsername;
            SelectedProfile.AdminPassword = e.Value.AdminPassword;
            ProfilesService.Save();

            _view.LoadProfilesDropdown(Profiles, SelectedProfile.ProfileName);
        }
Example #22
0
        public ActionResult Details(Guid id)
        {
            var svc           = new StylistsService(Guid.Parse(User.Identity.GetUserId()));
            var model         = svc.GetStylistById(id);
            var profilesvc    = new ProfilesService(Guid.Parse(User.Identity.GetUserId()));
            var userreviewsvc = new UserReviewService(Guid.Parse(User.Identity.GetUserId()));

            model.UserReviewListItem = userreviewsvc.GetUserReviewsByStylistID(id.ToString()).ToList();
            model.StylistProfile     = profilesvc.GetProfileByUserID(id.ToString());
            return(View(model));
        }
Example #23
0
        public void ShouldUpdateYourPetProfileWithImage()
        {
            var listImage     = new List <Image>();
            var mockRepoImage = new Mock <IDeletableEntityRepository <Image> >();

            mockRepoImage.Setup(x => x.All()).Returns(listImage.AsQueryable());
            mockRepoImage.Setup(x => x.AddAsync(It.IsAny <Image>()));
            mockRepoImage.Setup(x => x.Delete(It.IsAny <Image>()));

            var listPet     = new List <Pet>();
            var mockRepoPet = new Mock <IDeletableEntityRepository <Pet> >();

            mockRepoPet.Setup(x => x.All()).Returns(listPet.AsQueryable());
            mockRepoPet.Setup(x => x.AddAsync(It.IsAny <Pet>()));
            mockRepoPet.Setup(x => x.Delete(It.IsAny <Pet>()));

            var listUser     = new List <ApplicationUser>();
            var mockRepoUser = new Mock <IDeletableEntityRepository <ApplicationUser> >();

            mockRepoUser.Setup(x => x.All()).Returns(listUser.AsQueryable());
            mockRepoUser.Setup(x => x.Delete(It.IsAny <ApplicationUser>()));
            var service = new ProfilesService(mockRepoPet.Object, mockRepoUser.Object, mockRepoImage.Object);

            var imageList = new List <string>()
            {
                "vasko.com",
            };


            var pet = new Pet
            {
                BreedId       = 1,
                CityId        = 1,
                Id            = 1,
                Name          = "GoshoCat",
                DateOfBirth   = new DateTime(2008, 3, 1, 7, 0, 0),
                SpecieId      = 1,
                AddedByUserId = "PeshoId",
                Description   = "test",
                Images        = listImage,
            };

            listPet.Add(pet);
            var viewModel = new EditProfileInputModel
            {
                Description = "newTest",
                Id          = 1,
                Name        = "newGoshoCat",
            };

            service.UpdateAsync(1, viewModel, "PeshoId", imageList);
            Assert.Equal("newGoshoCat", pet.Name);
            Assert.Equal("newTest", pet.Description);
        }
Example #24
0
        private void SelectedProfileDeleted(object sender, EventArgs e)
        {
            ProfilesService.DeleteSelected();
            ProfilesService.Save();

            if (!Profiles.Any())
            {
                Presenter.CreateDummyProfile();
            }

            _view.LoadProfilesDropdown(Profiles, SelectedProfile?.ProfileName);
        }
Example #25
0
        public void ShouldReturnPetProfileInfo()
        {
            var listImage     = new List <Image>();
            var mockRepoImage = new Mock <IDeletableEntityRepository <Image> >();

            mockRepoImage.Setup(x => x.All()).Returns(listImage.AsQueryable());
            mockRepoImage.Setup(x => x.AddAsync(It.IsAny <Image>()));
            mockRepoImage.Setup(x => x.Delete(It.IsAny <Image>()));

            var listPet     = new List <Pet>();
            var mockRepoPet = new Mock <IDeletableEntityRepository <Pet> >();

            mockRepoPet.Setup(x => x.AllAsNoTracking()).Returns(listPet.AsQueryable());
            mockRepoPet.Setup(x => x.AddAsync(It.IsAny <Pet>()));
            mockRepoPet.Setup(x => x.Delete(It.IsAny <Pet>()));

            var listUser     = new List <ApplicationUser>();
            var mockRepoUser = new Mock <IDeletableEntityRepository <ApplicationUser> >();

            mockRepoUser.Setup(x => x.All()).Returns(listUser.AsQueryable());
            mockRepoUser.Setup(x => x.Delete(It.IsAny <ApplicationUser>()));
            var service  = new ProfilesService(mockRepoPet.Object, mockRepoUser.Object, mockRepoImage.Object);
            var comments = new List <Comment>();
            var images   = new List <Image>();
            var likes    = new List <Like>();
            var pet      = new SinglePetViewModel
            {
                SpecieName    = "Cat",
                AddedByUserId = "AddedByUserId",
                BreedName     = "British",
                CityName      = "Sofia",
                DateOfBirth   = new DateTime(2008, 3, 1, 7, 0, 0),
                Gender        = Gender.Male,
                Id            = 1,
                Email         = "Email",
                Images        = images.Select(x => new PetImagesViewModel {
                    ImageUrl = x.Url, Id = x.Id, CreatedOn = x.CreatedOn
                }).OrderByDescending(x => x.CreatedOn).ToList(),
                ImageUrl = "vasko.com",
                Name     = "PeshoCat",
                Likes    = likes.Select(x => new LikesPetViewModel {
                    Email = x.User.Email, PetId = x.Id, UserId = x.UserId, CreatedOn = x.CreatedOn
                }).ToList(),
                TotalLikes  = 2,
                Description = "Az sum kotka",
                Comments    = comments.Select(x => new PetCommentViewModel {
                    AddedByUserId = x.AddedByUserId, CreatedOn = x.CreatedOn, Description = x.Description, Id = x.Id, Email = x.AddedByUser.Email
                }).OrderByDescending(x => x.CreatedOn).ToList(),
            };

            service.PetProfileInfo(1);
        }
Example #26
0
        private void ProfileAdded(object sender, EventArgs <IProfileUserControl> e)
        {
            if (Presenter.Profiles.Count() == 1 && Presenter.Profiles.First() == Settings.ProfileNotCreated)
            {
                ProfilesService.DeleteSelected();
            }

            ProfilesService.Add(e.Value);
            ProfilesService.SelectProfile(e.Value.ProfileName);
            ProfilesService.Save();

            _view.LoadProfilesDropdown(Presenter.Profiles, Presenter.SelectedProfile.ProfileName);
        }
        // GET: api/Allergens
        public IEnumerable <Allergen> GetAllergens()
        {
            try
            {
                profilesService = new ProfilesService(User.Identity.Name);
            }
            catch (UserNotFoundException)
            {
                return(null);
            }

            return(profilesService.GetAllergens());
        }
 public HttpResponseMessage SelectById(int id)
 {
     try
     {
         ItemResponse <Profile> resp = new ItemResponse <Profile>();
         ProfilesService        svc  = new ProfilesService();
         resp.Item = svc.SelectById(id);
         return(Request.CreateResponse(HttpStatusCode.OK, resp));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
        public IHttpActionResult DeleteAllergen(int id)
        {
            try
            {
                profilesService = new ProfilesService(User.Identity.Name);
                profilesService.RemoveAllergen(id);
            }
            catch (Exception)
            {
                return(NotFound());
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #30
0
        public async Task UserExistsByNameAsync_WithValidUserName_ShouldReturnTrue()
        {
            // Arrange
            var context                = InMemoryDbContext.Initiliaze();
            var userRepository         = new EfDeletableEntityRepository <ApplicationUser>(context);
            var userFollowerRepository = new EfRepository <UserFollower>(context);
            var profileService         = new ProfilesService(userRepository, userFollowerRepository);

            await this.SeedUsers(context);

            // Act
            bool result = await profileService.UserExistsByNameAsync("userOneUsername");

            // Assert
            Assert.True(result);
        }