public SignUpService CreateSignUpService() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new SignUpService(userId); return(service); }
public void GivenUserNotAlreadyInDb_WhenDeleteAccountCalled_ReturnTrue() { using (var scope = Container.BeginLifetimeScope()) { // Arrange User user = _mockData.FakeUser2; UserSignUpViewModel signUpViewModel = new UserSignUpViewModel() { FirstName = user.FirstName, LastName = user.LastName, City = user.City, Email = user.Email, Password = user.Password }; _profilesService = scope.Resolve <ProfileService>(); _signUpService = scope.Resolve <SignUpService>(); // Act var result = _profilesService.DeleteUserAccount(user); // Assert Assert.That(result, Is.Not.Null); Assert.That(result, Is.InstanceOf <bool>()); Assert.That(result, Is.EqualTo(false)); } }
public HttpResponseMessage Login(LoginInModel lim) { StringContent stringContent; ProjectResponse response = new ProjectResponse(); var result = new UserModel(); var sps = new SignUpService(); try { result = sps.Login(lim); } catch (DataException de) { response.internalcode = de.Info; if (de.Info == "21") { response.status = "IOerror"; stringContent = new StringContent(JsonConvert.SerializeObject(response), Encoding.UTF8, "application/json"); } else if (de.Info == "3") { response.status = "Passworderror"; stringContent = new StringContent(JsonConvert.SerializeObject(response), Encoding.UTF8, "application/json"); } else if (de.Info == "2") { response.status = "UserNotexist"; stringContent = new StringContent(JsonConvert.SerializeObject(response), Encoding.UTF8, "application/json"); } else { response.status = "Unknownerror"; stringContent = new StringContent(JsonConvert.SerializeObject(response), Encoding.UTF8, "application/json"); } HttpResponseMessage hrm = new HttpResponseMessage(); hrm.Content = stringContent; return(hrm); } var resp = new HttpResponseMessage(); var nv = new NameValueCollection(); nv["user"] = result.Name; nv["username"] = result.UserName; nv["id"] = result.Id; var cookie = new CookieHeaderValue("session", nv); response.internalcode = "1"; response.status = "success"; resp.Content = new StringContent(JsonConvert.SerializeObject(response), Encoding.UTF8, "application/json"); resp.Headers.AddCookies(new CookieHeaderValue[] { cookie }); return(resp); }
public AuthService(AuthenticationStateProvider authenticationStateProvider, ServerHandler serverHandler, SignUpService signUpService, SignInService signInService) { this.authenticationStateProvider = authenticationStateProvider; this.serverHandler = serverHandler; this.signUpService = signUpService; this.signInService = signInService; }
// GET: SIGNUP public ActionResult Index() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new SignUpService(userId); var model = service.GetSignUp(); var evtsvc = CreateEventService(); var eventDetail = evtsvc.GetEvents(); var volsvc = CreateVolunteerService(); var volDetail = volsvc.GetVolunteers(); return(View(model)); }
public IActionResult Index(SignUp signUp) { try { var email = new SignUpService(signUp); email.SendCreateAccountReminderEmail(); email.SendRegistrationEmail(); return(RedirectToAction("Index")); } catch (Exception e) { return(RedirectToAction("Index")); } }
public async Task TestMethod_Can_Signup_A_Person_Successfully() { ISignUpService wcf = new SignUpService(); string random = Guid.NewGuid().ToString(); SignupInput signupInput = new SignupInput { FirstName = "Wcf", LastName = "Test", Email = random.Substring(1, 10) + "@wcf.com", FunEventId = 100, Comments = "Created by Wcf" }; var signupResult = await wcf.Add(signupInput); Assert.IsTrue(signupResult.Status == OperationStatus.Added); Assert.IsTrue(signupResult.Errors.Count == 0); Assert.IsTrue(signupResult.ResourceId == string.Format("{0}###{1}", signupInput.Email, signupInput.FunEventId)); }
public void SignUp_Service_Update_Method_Throws_NullReferenceException_With_Invalid_ValueType() { //Arrange User master = new User(); master.Id = 1; var request = new User(); var mockRepo = new Mock <ISignUpRepository>(); mockRepo.Setup(x => x.Update(It.IsAny <String>(), It.IsAny <User>())).Throws(new NullReferenceException()); SignUpService obj = new SignUpService(mockRepo.Object); var exception = Record.Exception(() => obj.Update(It.IsAny <string>(), It.IsAny <User>())); Assert.IsType <NullReferenceException>(exception); }
public string Signup(SignUpModel sum) { var cookie = ActionContext.Request.Headers.GetCookies("Bar").FirstOrDefault(); var sps = new SignUpService(); var result = sps.Signup(sum); if (result == 1) { return("success"); } else { return(result.ToString()); } }
protected override async Task Register() { var address = new AddressM { Country = "Россия", Province = Province.Value, Locality = City.Value, District = Region.Value }; Model.GarageAddress = address; var company = Mapper.Map <DispatcherCompanyDM>(Model); await SignUpService.RegisterDispatcher(company, RequestPriority.UserInitiated); await NavigationService.Navigate <FinishedSignUpViewModel>(); }
public SignUpServiceTestsSuite() { DomainDriverServiceMock = new Mock <IDriverService>(); DomainDispatcherServiceMock = new Mock <IDispatcherService>(); DomainCompanyServiceMock = new Mock <ICompanyService>(); DomainGarageServiceMock = new Mock <IGarageService>(); VehicleServiceMock = new Mock <IApplicationVehicleService>(); SignUpService = new SignUpService( TransactionServiceMock.Object, DomainDriverServiceMock.Object, DomainDispatcherServiceMock.Object, DomainCompanyServiceMock.Object, DomainGarageServiceMock.Object, VehicleServiceMock.Object); }
public void SignUp_Service_Get_by_Id_Method_Type_Object() { //Arrange //List<Master> requests = new List<Master>(); var request = new User(); request.Id = 1; var mockRepoReq = new Mock <ISignUpRepository>(); //mocking RequestRepository mockRepoReq.Setup(x => x.GetById(1)).Returns(request); SignUpService obj = new SignUpService(mockRepoReq.Object); //Act var res = obj.GetById(1); //Assert Assert.IsType <User>(res); }
public void SignUpService_Add_User_Method_Throws_NullReference_Exception() { //Arrange //List<Master> requests = new List<Master>(); User re = new User(); re.Id = 1; var mockRepoReq = new Mock <ISignUpRepository>(); //mocking RequestRepository mockRepoReq.Setup(x => x.Add_User(It.IsAny <User>())).Throws(new NullReferenceException()); SignUpService obj = new SignUpService(mockRepoReq.Object); //Act var exception = Record.Exception(() => obj.Add_User(It.IsAny <User>())); //Assert Assert.IsType <NullReferenceException>(exception); }
public void SignUpService_GetId_Method() { //Arrange //List<Master> requests = new List<Master>(); User request = new User(); request.Id = 1; var mockRepoReq = new Mock <ISignUpRepository>(); //mocking RequestRepository mockRepoReq.Setup(x => x.Get(It.IsAny <String>())).Returns(request); SignUpService obj = new SignUpService(mockRepoReq.Object); //Act var res = obj.GetId(It.IsAny <String>()); //Assert Assert.NotNull(res); // Assert.Equal(request, res); }
public void SignUpService_Add_User_Method_Throws_Format_Exception() { //Arrange //List<Master> requests = new List<Master>(); User re = new User(); re.Id = 1; re.Email = "*****@*****.**"; var mockRepoReq = new Mock <ISignUpRepository>(); //mocking RequestRepository mockRepoReq.Setup(x => x.Add_User(re)).Throws(new FormatException()); SignUpService obj = new SignUpService(mockRepoReq.Object); //Act var exception = Record.Exception(() => obj.Add_User(re)); //Assert Assert.IsType <FormatException>(exception); }
private void ClientHandle(object c) { TcpClient Client = (TcpClient)c; NetworkStream ns = Client.GetStream(); string[] Messages = CryptDecryptData.DecryptData(_Utils.ReadStreamString(ns)); switch (Messages[0]) { case "LOGIN": LoginService.Handle(Client, ns, Messages); break; case "SIGNUP": SignUpService.Handle(Client, ns, Messages); break; } }
public void SignUp_Service_GetAllDetails_Method_To_Get_Details_Type_Object() { //Arrange List <User> requests = new List <User>(); var request = new User(); request.Id = 1; requests.Add(request); //mocking RequestRepository var mockRepoReq = new Mock <ISignUpRepository>(); //mocking GetAll() of RequestRepository mockRepoReq.Setup(x => x.GetAllDetails()).Returns(requests); SignUpService obj = new SignUpService(mockRepoReq.Object); //Act var res = obj.GetAllDetails(); //Assert Assert.IsType <List <User> >(res); }
private void signUpbutton_Click(object sender, EventArgs e) { string gen = null; if (maleRadioButton.Checked) { gen = maleRadioButton.Text; } else { gen = femaleRadioButton.Text; } if (nameTextBox.Text == "" || userNameTextBox.Text == "" || passwordTextBox.Text == "" || emailTextBox.Text == "" || checkBox1.Checked == false || dateTimePicker1.Text == "") { MessageBox.Show("Fill up the requirde from"); } else if (passwordTextBox.Text != confirmPasswordTextBox.Text) { MessageBox.Show("Password not match"); } else if (maleRadioButton.Checked == false && femaleRadioButton.Checked == false) { MessageBox.Show("Fill up the erquired from"); } else { SignUpService signUpService = new SignUpService(); int result = signUpService.InsertUser(nameTextBox.Text, userNameTextBox.Text, passwordTextBox.Text, emailTextBox.Text, dateTimePicker1.Text, gen); if (result > 0) { MessageBox.Show("Account create successfully"); LoginFrom loginFrom = new LoginFrom(); loginFrom.Show(); this.Hide(); } else { MessageBox.Show("Error occur"); } } }
public IHttpActionResult PostQuizAnswers([FromBody] dynamic answers) { var headers = Request.Headers; var token = headers.GetValues("token").First(); JwtToken jwt = new JwtToken(); int fanId = jwt.GetIdFromToken(token); List <ArtistLastFmModel> ratings = answers.ratings.ToObject <List <ArtistLastFmModel> >(); List <GenreModelForSelector> genres = answers.genres.ToObject <List <GenreModelForSelector> >(); try { var signUpService = new SignUpService(); signUpService.PostQuizAnswers(fanId, ratings, genres); } catch (InvalidModelException ex) { return(BadRequest(ex.Message)); } return(Ok(new { code = "200", message = "Quiz successful" })); }
public IHttpActionResult SignUpFan([FromBody] User user) { var signUpService = new SignUpService(); try { User addedUser = signUpService.SignUpFan(user.Name, user.Password, user.Email); var _authToken = new JwtToken(); var token = _authToken.CreateJwt("MusicApp", addedUser.Id, addedUser.Name, addedUser.Role, 10000); return(Ok(token)); } catch (InvalidModelException ex) { return(BadRequest(ex.Message)); } catch { return(BadRequest()); } }
public void SignUp_Service_Check_Method_To_Get_Details() { //Arrange var idPass = new IdPassword(); idPass.Email = "preetam"; idPass.Password = "******"; User master = new User(); master.Email = "preetam"; master.Password = "******"; master.FirstName = "preetam"; master.Id = 1; var creadential = new Creadential(); creadential.UserId = 1; creadential.Status = "success"; creadential.UserName = "******"; creadential.Email = "preetam"; //mocking RequestRepository var mockRepoReq = new Mock <ISignUpRepository>(); //mocking GetAll() of RequestRepository mockRepoReq.Setup(x => x.Get(creadential.Email)).Returns(master); mockRepoReq.Setup(x => x.SetLoggedIn(1, true)).Returns(true); SignUpService obj = new SignUpService(mockRepoReq.Object); //Act var res = obj.Check(idPass); //Assert Assert.NotNull(res); Assert.Equal(creadential.Email, res.Email); Assert.Equal(creadential.Status, res.Status); Assert.Equal(creadential.UserName, res.UserName); Assert.Equal(creadential.UserId, res.UserId); }
public IHttpActionResult SignUpArtist([FromBody] dynamic artist) { var signUpService = new SignUpService(); try { List <GenreModelForSelector> genres = artist.genres.ToObject <List <GenreModelForSelector> >(); User addedUser = signUpService.SignUpArtist(artist.Name.ToString(), artist.Password.ToString(), artist.Email.ToString(), genres); var _authToken = new JwtToken(); var token = _authToken.CreateJwt("MusicApp", addedUser.Id, addedUser.Name, addedUser.Role, 10000); return(Ok(token)); } catch (InvalidModelException ex) { return(BadRequest(ex.Message)); } catch { return(BadRequest()); } }
public SignUpPage() { InitializeComponent(); _signUpService = new SignUpService(); }
public SignUpCommandHandler(SignUpService service) { _service = service; }
public SignUpController(SignUpService service, ILogger <SignUpController> logger) { this.service = service; this.logger = logger; }