/// <summary> /// Edits the profile information /// </summary> /// <param name="obj"></param> /// <returns></returns> public ResponseDTO <Boolean> EditProfile(ProfileDTO obj, HttpPostedFile image) { ResponseDTO <bool> response = new ResponseDTO <bool>(); UserProfileGateway userProfileDb = new UserProfileGateway(); // Passing Files into the validations if (obj.IsUpdatingProfileImage == "true") { if (!ValidateImage(image)) { response.IsSuccessful = false; response.Messages.Add("Invalid Data"); return(response); } obj.ProfilePicture = SaveImage(image, obj.UserName); userProfileDb.EditProfileImage(obj); } if (!ValidateProfileData(obj)) { // Validations failed for at least one of the data response.IsSuccessful = false; response.Messages.Add("Invalid Data"); return(response); } // Storing data response = userProfileDb.EditProfile(obj); return(response); }
/// <summary> /// /// </summary> /// <param name="userName"></param> /// <returns></returns> public ResponseDTO <ProfileDTO> GetProfile(UsernameDTO obj) { // Creates ResponseDTO for transfering data and error messages between layers. ResponseDTO <ProfileDTO> response = new ResponseDTO <ProfileDTO>(); if (!ValidateUserName(obj.Username)) { response.IsSuccessful = false; response.Messages.Add("Invalid userName."); return(response); } // Creating Profile Gateway to access data UserProfileGateway userProfileDb = new UserProfileGateway(); // sending data from Gateway back to response object response = userProfileDb.GetProfile(obj); return(response); }
public void EditProfileTest() { // Arrange UserProfileGateway temp = new UserProfileGateway(); ProfileDTO obj = new ProfileDTO() { UserName = "******", FirstName = "aasdf", LastName = "dfegv", Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent quis nunc ac arcu congue luctus. Nulla ligula sapien, sodales fringilla ligula sit amet, gravida sagittis turpis. Nunc tincidunt est vel risus lobortis laoreet. Suspendisse feugiat metus ac egestas tempor.", SkillLevel = "Advance", Gender = "Male", ProfilePicture = "../../assets/Images/ProfileDummy/profilePicture.jpg" }; // Act // var response = temp.EditProfile(obj); // Assert //Assert.True(response.IsSuccessful); }
public void GetUserProfileGatewayTest() { // Arrange UserProfileGateway temp = new UserProfileGateway(); UsernameDTO obj = new UsernameDTO() { Username = "******" }; // Act var response = temp.GetProfile(obj); // Assert Assert.True(response.IsSuccessful); Assert.Equal("April", response.Data.FirstName); Assert.Equal("May", response.Data.LastName); Assert.Equal("Female", response.Data.Gender); Assert.Equal("Beginner", response.Data.SkillLevel); Assert.Equal("SomeDescription", response.Data.Description); Assert.Null(response.Data.ProfilePicture); }