public void ShouldNotUpdateCustomerAndReturnError() { var request = new CustomerSaveRequest(CustomerId, "", 18, "*****@*****.**"); customerSaveUseCase.Execute(request); presenter.ViewModel.Should().BeOfType <BadRequestObjectResult>(); }
public void ShouldNotExecute() { var request = new CustomerSaveRequest("", 18, "*****@*****.**"); Action act = () => validateHandler.ProcessRequest(request); act.Should().Throw <ArgumentException>(); }
public void ShouldUpdateCustomerAndReturnOK() { var request = new CustomerSaveRequest(CustomerId, "CustomerTestUpdated", 25, "*****@*****.**"); customerSaveUseCase.Execute(request); presenter.ViewModel.Should().BeOfType <OkObjectResult>(); }
public IActionResult UpdateCustomer([FromBody] InputCustomer input) { var request = new CustomerSaveRequest(input.Id, input.Name, input.Age, input.Email); customerSaveUseCase.Execute(request); return(presenter.ViewModel); }
public void ShouldSave() { var request = new CustomerSaveRequest("CustomerTest", 18, "*****@*****.**"); Action act = () => saveHandler.ProcessRequest(request); act.Should().NotThrow <ArgumentException>(); }
public void ShouldAddNewCustomerAndReturnOK() { var request = new CustomerSaveRequest("CustomerTest", 18, "*****@*****.**"); CustomerId = request.Customer.Id; customerSaveUseCase.Execute(request); presenter.ViewModel.Should().BeOfType <OkObjectResult>(); }
public ProcessResponse RegisterUser(CustomerSaveRequest request) { ProcessResponse pr = new ProcessResponse(); var apiResponse = _userMgmtRepository.RegisterUser(request, APIUri.RegiserUser); if (apiResponse.Succeded) { pr = apiResponse.Response; } return(pr); }
public HttpResponseMessage RegisterUser(CustomerSaveRequest request) { try { var result = _userManagementService.RegisterUser(request); return(Request.CreateResponse <ApiResponse <ProcessResponse> >(HttpStatusCode.OK, result)); } catch (Exception ex) { return(Request.CreateResponse <System.Exception>(HttpStatusCode.InternalServerError, ex)); } }
public ApiResponse <ProcessResponse> RegisterUser(CustomerSaveRequest customerSave) { ProcessResponse ps = new ProcessResponse(); try { Customer c = new Customer(); c.Active = true; c.AdminComment = customerSave.AdminComment; c.AffiliateId = customerSave.AffiliateId; c.BillingAddress_Id = 0; c.CannotLoginUntilDateUtc = null; c.CreatedOnUtc = DateTime.Now; c.CustomerType = customerSave.CustomerType; c.Deleted = false; c.Email = customerSave.Email; c.EmailToRevalidate = customerSave.EmailToRevalidate; c.FailedLoginAttempts = 0; c.HasShoppingCartItems = false; c.IsSystemAccount = false; c.IsTaxExempt = false; c.LastActivityDateUtc = DateTime.Now; c.RegisteredInStoreId = 0; c.RequireReLogin = false; c.ShippingAddress_Id = 0; c.SystemName = null; c.Username = customerSave.FirstName + " " + customerSave.LastName; c.VendorId = 0; c = _userManagmentRepository.RegisterCustomer(c); if (c.Id > 0) { CustomerAddresses ca = new CustomerAddresses(); CustomerPassword cp = new CustomerPassword(); Address add = new Address(); cp.CustomerId = c.Id; cp.Password = customerSave.password; cp.CreatedOnUtc = DateTime.Now; ps = _userManagmentRepository.SavePassword(cp); add.Address1 = customerSave.Address1; add.Address2 = customerSave.Address2; add.City = customerSave.City; add.Company = customerSave.Company; add.CountryId = customerSave.CountryId; add.CreatedOnUtc = DateTime.Now; add.Email = customerSave.Email; add.FaxNumber = customerSave.FaxNumber; add.FirstName = customerSave.FirstName; add.LastName = customerSave.LastName; add.PhoneNumber = customerSave.PhoneNumber; add.StateProvinceId = customerSave.StateProvinceId; add.ZipPostalCode = customerSave.ZipPostalCode; add = _userManagmentRepository.SaveAddress(add); ca.Address_Id = add.Id; ca.Customer_Id = c.Id; ps = _userManagmentRepository.SaveCustomerAddress(ca); ps.CurrentId = c.Id; } } catch (Exception ex) { ps.Message = "Failed to save " + ex.ToString(); ps.StatusCode = 0; ps.CurrentId = 0; } return(Transform.ConvertResultToApiResonse(ps)); }
public ApiResponse <ProcessResponse> RegisterUser(CustomerSaveRequest request, string Uri) { return(_ecommerceProxy.PostApi <CustomerSaveRequest, ProcessResponse>(request, Uri, "Post")); }
public ActionResult Register(CustomerSaveRequest request) { List <ServiceCategoriesResponse> serviceDrop = new List <ServiceCategoriesResponse>(); List <CategoryDropHomeResponse> catDropsHome = new List <CategoryDropHomeResponse>(); if (Session["CatDrop"] != null) { catDropsHome = (List <CategoryDropHomeResponse>)Session["CatDrop"]; } if (Session["ServiceDrop"] != null) { serviceDrop = (List <ServiceCategoriesResponse>)Session["ServiceDrop"]; } ViewBag.CatsDrop = catDropsHome; ViewBag.ServiceDrop = serviceDrop; ViewBag.ErrorMessage = ""; List <USPGetCountriesListResponse> Countries = new List <USPGetCountriesListResponse>(); Countries = _categoryManagementService.GetCountries(); ViewBag.CountryId = Countries; int? CountryIdSelected = 0; int? StateIdSelected = 0; string CityIdSelected = string.Empty; if (request.CountryId > 0) { CountryIdSelected = request.CountryId; } if (request.StateProvinceId > 0) { StateIdSelected = request.StateProvinceId; } if (!string.IsNullOrEmpty(request.City)) { CityIdSelected = request.City; } if (ModelState.IsValid) { //check for emailavalable ProcessResponse ps = new ProcessResponse(); LoginRequest lr = new LoginRequest(); lr.emailId = request.Email; ps = _userManagementService.EmailAvailableCheck(lr); if (ps.StatusCode == 0) { ModelState.AddModelError("Email", "Emailid not avaialble"); } } if (ModelState.IsValid) { ProcessResponse pr = new ProcessResponse(); pr = _userManagementService.RegisterUser(request); if (pr.CurrentId > 0) { return(RedirectToAction("RegistrationSuccess", new { UserType = request.CustomerType, Id = pr.CurrentId })); } else { ViewBag.ErrorMessage = "Unable to register now, please try later : " + pr.Message; return(View(request)); } } return(View(request)); }