public ActionResult Register(RegisterCustomerModel model) { var result = new Dictionary<string, object> { ["isSuccess"] = false, ["error"] = "Something was wrong. Customer has not been added to the database" }; if (!this.ModelState.IsValid) return this.Json(result, JsonRequestBehavior.DenyGet); var hashedPassword = HelperConverter.DoubleMD5Hash(model.Password); var helper = new HelperRepository(); var insertedCustomerId = helper.InsertCustomer( model.FirstName, model.MiddleName, model.LastName); helper.InsertUser(insertedCustomerId, model.Email, hashedPassword, model.RoleId); result["success"] = $"Customer {model.FirstName} {model.LastName} has successfully added to the database"; result["model"] = HelperConverter.GetCustomerRowJsonString(insertedCustomerId); result["isSuccess"] = true; return this.Json(result, JsonRequestBehavior.DenyGet); }
public IActionResult NewCust(RegisterCustomerModel model) { List <Customer> C = _context.Customers.Where(s => s.Name != null).ToList(); Customer Check = _context.Customers.Where(c => c.Name == model.Name).SingleOrDefault(); if (ModelState.IsValid) { if (Check == null) { Customer NewCust = new Customer(); NewCust.Name = model.Name; NewCust.Created_at = DateTime.Now; NewCust.Updated_at = DateTime.Now; _context.Customers.Add(NewCust); _context.SaveChanges(); return(Redirect("Customers")); } else { TempData["Error"] = "Name already in system"; return(Redirect("Customers")); } } ViewBag.Custs = C; return(View("Customer")); }
public bool Add(RegisterCustomerModel model) { RegisterCustomerEntity entity = AutoMapperHelper.DoMap <RegisterCustomerModel, RegisterCustomerEntity>(model); entity.CreateDate = DateTime.Now; entity.UpdateDate = DateTime.Now; return(_registerCustomerDal.Inster(entity) > 0); }
public async Task <Guid> PostAsync([FromBody] RegisterCustomerModel model) { var command = _mapper.Map <RegisterCustomer>(model); //ToDo:3 command.InitiatorId = User.Identity.Id; command.InitiatorId = Guid.NewGuid(); await _commandInvoker.Execute(command); return(command.Id); }
public HandsetRental Post([FromBody] RegisterCustomerModel customerDetails) { var language = this._languageService.GetLanguage(customerDetails.LanguageId); var knowledgeLevel = this._knowledgeLevelService.GetKnowledgeLevel(customerDetails.KnowledgeLevelId); var customer = this._customerService.CreateCustomer(customerDetails.Name, customerDetails.Email, customerDetails.Mobile, customerDetails.Address, language, knowledgeLevel); var rental = this._handsetService.RentHandset(customer); return(rental); }
public ActionResult Signup(RegisterCustomerModel model) { model.RoleId = 1; var message = "Something was wrong. You are has not been registered"; if (!this.ModelState.IsValid) return this.Json(message, JsonRequestBehavior.DenyGet); var hashedPassword = HelperConverter.DoubleMD5Hash(model.Password); var helper = new HelperRepository(); var insertedCustomerId = helper.InsertCustomer( model.FirstName, model.MiddleName, model.LastName); helper.InsertUser(insertedCustomerId, model.Email, hashedPassword, model.RoleId); return this.RedirectToAction("Login", "Account"); }
// GET: MailTemplate public ActionResult Register(RegisterCustomerModel model) { ViewBag.Subject = "Customer Registration"; return(View(model)); }
public ActionResult Register(RegisterCustomerModel model) { bool statusRegistration = false; string messageRegistration = string.Empty; if (ModelState.IsValid) { // Email Verification string userName = Membership.GetUserNameByEmail(model.Email); if (!string.IsNullOrEmpty(userName)) { ModelState.AddModelError("Warning Email", "Sorry: Email already Exists"); return(View(model)); } //Save User Data var customer = new Customer() { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Contactno = model.Contactno, Username = model.Email, Password = model.Password, CompanyName = model.CompanyName, Date_of_Registration = DateTime.Now, IsActive = false, createddate = DateTime.Now, updateddate = DateTime.Now, ActivationCode = Guid.NewGuid() }; var role = RoleService.GetRoleByName("User"); CustomerRole customerrole = new CustomerRole(); if (role != null) { customerrole.RoleId = role.RoleId; customerrole.CustomerId = customer.CustomerId; } customer.CustomerRoles.Add(customerrole); CustomerService.InsertCustomer(customer); //Verification Email VerificationEmail(model.FirstName, model.LastName, model.Email, customer.ActivationCode.ToString()); messageRegistration = "Congratulations! You have successfully created your account.Please check your email for instruction to activate your account."; statusRegistration = true; Transaction transaction = new Transaction(); transaction.CustomerId = customer.CustomerId; transaction.Amount = 100; transaction.TransactionDate = DateTime.Now; transaction.Status = "completed"; transaction.TransactionType = "credit"; transaction.CreatedDate = DateTime.Now; transaction.UpdatedDate = DateTime.Now; transaction.PaymentMethod = "offline"; TransactionService.InsertTransaction(transaction); ViewBag.Message = messageRegistration; ViewBag.Status = statusRegistration; } return(View(model)); }
public ActionResult Register() { RegisterCustomerModel model = new RegisterCustomerModel(); return(View(model)); }