public ActionResult Edit(Customer collection)
        {
            try
            {
                // TODO: Add update logic here

                _customer.EditCustomer(collection);

                return RedirectToAction("Index","Home");
            }
            catch
            {
                return View();
            }
        }
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email, isAdmin = 1, CompCode = Guid.NewGuid() };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
                    Guid compguid = user.CompCode;
                    var cust = new Customer
                    {
                        Address = model.Address,
                        City = model.City,
                        ContactName = model.ContactName,
                        County = model.County,
                        Email = model.Email,
                        Fax = model.Fax,
                        RegistrationNo = model.RegistrationNo,
                        CompCode = compguid,
                        NursingHomeName = model.NursingHomeName,
                        Phone = model.Phone

                    };
                    _customer.CreateCustomer(cust);

                   
                    var custs = _customer.getCompanyByGuid(user.CompCode);
                    Session["CustID"] = custs.CustomerID;
                    Session["NursingHomeName"] = custs.NursingHomeName;

                    return RedirectToAction("Home", "Home");

                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 3
0
 public void EditCustomer(Customer customer)
 {
     _customerRepository.Update(customer);
     _unitOfWork.Save();
 }
Ejemplo n.º 4
0
 public void CreateCustomer(Customer customer)
 {
     _customerRepository.Add(customer);
     _unitOfWork.Save();
 }