public IActionResult Registration(CustomerCreateVm model) { if (!ModelState.IsValid) { return(View()); } if (_serviceCustomer.GetUser(model.Mail) == true) { ViewBag.check = 0; return(View()); } else { string passHash; using (MD5 md5Hash = MD5.Create()) { passHash = MD5Hash.GetMd5Hash(md5Hash, model.Password); } SaveUserDto saveUserDto = new SaveUserDto() { FirstName = model.FirstName, LastName = model.LastName, Mail = model.Mail, Password = passHash }; _serviceCustomer.Add(saveUserDto); ViewBag.check = 1; return(View()); } }
public async Task <ActionResult <Customer> > Create(CustomerCreateVm vm) { var customer = new Customer() { Name = vm.Name, Number = vm.Number }; _db.Customers.Add(customer); await _db.SaveChangesAsync(); return(CreatedAtAction(nameof(Get), new { id = customer.Id }, customer)); }