public HttpResponseMessage GetUserwise([FromBody] int LocationId, [FromUri] string id, [FromUri] int type) { List <RegisterOut> RegisterOuts = RegisterIn.GetDetailsUserWise(LocationId, id, type).Where(x => x.Status == 0).ToList(); RegisterOuts.ForEach(x => x.Products.RemoveAll(y => y.Status != 0)); return(Request.CreateResponse(HttpStatusCode.OK, RegisterOuts)); }
/// <summary> /// Get registry value string /// </summary> /// <param name="register">target office application</param> /// <returns>registry sub string from office application</returns> internal static string RegistryEntry(RegisterIn register) { if (register == RegisterIn.MSProject) return "MS Project"; // Visio use one empty space. Some previous NetOffice(<1.7.3) releases handle this not as well else return register.ToString(); }
public HttpResponseMessage Delete([FromUri] int Id, [FromBody] int modifiedBy) { RegisterIn ri = new RegisterIn(); ri.ID = Id; ri.ModifiedBy = modifiedBy; return(Request.CreateResponse(HttpStatusCode.OK, ri.Delete())); }
public async Task <ActionResult <RegisterOut> > register([FromBody] RegisterIn registerObject) { // check null object if (Utils.RepositoryUtils.isObjectEmpty <RegisterIn>(registerObject) || registerObject == null) { return(BadRequest()); } // host string creation for local: 'https://localhost:5001' string host = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}{HttpContext.Request.PathBase}"; // check already exists later var result = await _customerRepository.GetAny("email", registerObject.email); var tempUser = result.FirstOrDefault(); if (tempUser != null) { if (tempUser.verified == true) { // ! redirect to sign in page return(Ok(new { error = "This email address already exists" })); } else { // send verification link page var tempID = Utils.RepositoryUtils.getVal(tempUser, "Id"); return(Ok(new { error = "This email address already exists please verify your email", Link = $"{host}/api/users/verify?id={tempID}" })); } } var salt = BCrypt.Net.BCrypt.GenerateSalt(); string passwordHash = BCrypt.Net.BCrypt.HashPassword(registerObject.password, salt); User user = _mapper.Map <User>(registerObject); // ! generate persons wallet // ! remove dummy wallet id generation user.walletID = BCrypt.Net.BCrypt.HashPassword("dummy wallet").ToString(); user.passwordHash = passwordHash; user.verified = false; string id; try { id = await _customerRepository.Create(user); } catch { // status code not modified return(StatusCode(304)); } // // send mail for next step // var To = registerObject.email; // var Subject = "Verify your account"; // var Body = $"Please verify your email address by clicking here to move on to the next step in your energy trading platform membership. {Environment.NewLine} <br /><b><a href='{host}/api/v1/users/verify?id={id}'>Verify My Account</a></b>"; // _emailSender.Send(To, Subject, Body); var userOut = _mapper.Map <RegisterOut>(user); return(Created("", userOut)); }
/// <summary> /// Get registry value string /// </summary> /// <param name="register">target office application</param> /// <returns>registry sub string from office application</returns> internal static string RegistryEntry(RegisterIn register) { if (register == RegisterIn.MSProject) { return("MS Project"); // Visio use one empty space. Some previous NetOffice(<1.7.3) releases handle this not as well } else { return(register.ToString()); } }
/// <summary> /// Get registry value string /// </summary> /// <param name="register">target office application</param> /// <returns>registry sub string from office application</returns> internal static string RegistryEntry(RegisterIn register) { if (register == RegisterIn.MSProject) { return("MS Project"); } else { return(register.ToString()); } }
public HttpResponseMessage Save(RegisterIn ri) { if (ri.ID > 0) { return(Request.CreateResponse(HttpStatusCode.OK, ri.Update())); } else { return(Request.CreateResponse(HttpStatusCode.OK, ri.Save())); } }
public async Task <RegisterOut> Post([FromBody] RegisterIn model) { if (!ModelState.IsValid) { throw new InvalidModelStateException(ModelState); } var user = Map(model); user = await _service.RegisterUser(user); return(Map(user)); }
public async Task UnprocessableEntity_If_Two_Users_Are_Registered_With_Same_Email() { var user = new RegisterIn { Email = "*****@*****.**", Name = "Name", Password = "******" }; using (var client = CreateClient()) using (var json = CreateJson(user)) { var postResult = await client.PostAsync($"/v1/Register", json); postResult.StatusCode.Should().Be(HttpStatusCode.OK); postResult = await client.PostAsync($"/v1/Register", json); postResult.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); } }
public async Task User_Is_Created_And_Retrieven_Successfully() { var user = new RegisterIn { Email = "*****@*****.**", Name = "Name", Password = "******" }; var expected = new RegisterOut { Email = user.Email, Name = user.Name }; using (var client = CreateClient()) using (var json = CreateJson(user)) { var postResult = await client.PostAsync($"/v1/Register", json); Assert.Equal(HttpStatusCode.OK, postResult.StatusCode); var postJson = await postResult.Content.ReadAsStringAsync(); JsonConvert.DeserializeObject <RegisterOut>(postJson).Should().BeEquivalentTo(expected); await Authenticate(client, user.Email, user.Password); var getResult = await client.GetAsync("/v1/Register"); Assert.Equal(HttpStatusCode.OK, getResult.StatusCode); var getJson = await getResult.Content.ReadAsStringAsync(); JsonConvert.DeserializeObject <RegisterOut>(getJson).Should().BeEquivalentTo(expected); } }
private User Map(RegisterIn register) => _mapper.Map <RegisterIn, User>(register);
public HttpResponseMessage Get([FromUri] int Id, [FromBody] int LocationId) { return(Request.CreateResponse(HttpStatusCode.OK, RegisterIn.GetDetails(Id, LocationId))); }
public HttpResponseMessage Get([FromBody] int LocationId, [FromUri] DateTime?from, [FromUri] DateTime?to) { return(Request.CreateResponse(HttpStatusCode.OK, RegisterIn.GetDetails(LocationId, from, to))); }