public ActionResult Edit(SupplierViewModel item)
        {
            try
            {
                //if (User.IsInRole("Admin"))
                //{
                //}

                return RedirectToAction("Login", "Account");
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }
예제 #2
0
        public async Task<ActionResult> RegisterSupplier(RegisterSupplierViewModel model)
        {
            if (ModelState.IsValid)
            {
                var activationCode = CodeGenerator();
                var supplier = new SupplierViewModel()
                {
                    UserName = model.Email,
                    Email = model.Email,
                    DtCreated = DateTime.UtcNow,
                    Name = model.Name,
                    FirstName = model.FirstName,
                    LastName = model.LastName,
                    Website = model.Website,
                    Status = "Pending",
                    PhoneNumber = model.PhoneNumber,
                    ActivationCode = activationCode,
                    CommissionId = (from c in db.Commissions
                                    where c.Name == "Tier1"
                                    select c.CommissionId).FirstOrDefault()
                };
                var result = await UserManager.CreateAsync(supplier, model.Password);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(supplier, isPersistent: false, rememberBrowser: false);

                    ApplicationUser user = db.Users.Where(u => u.Email.Equals(model.Email, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                    if (user != null) UserManager.AddToRole(user.Id, "Supplier");

                    // 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>");

                    return RedirectToAction("Login", "Account", new { message = ManageMessageId.ActivationSupplierSuccess });
                }

                return RedirectToAction("Login", "Account", new { message = ManageMessageId.Error });

                //AddErrors(result);
            }
            return View(model);
        }
예제 #3
0
        private AdminUpdateSupplierRoleViewModel AssignSupplierDetailsForUpdate(SupplierViewModel record)
        {
            if (record == null || String.IsNullOrWhiteSpace(record.Id))
                return null;

            var itemToUpdate = new AdminUpdateSupplierRoleViewModel()
            {
                UserId = record.Id,
                Email = record.Email,
                Status = record.Status,
                UserRoles = db.Roles.OrderBy(x => x.Name).ToList()
            };

            if (itemToUpdate == null || String.IsNullOrWhiteSpace(itemToUpdate.UserId))
                return null;

            return itemToUpdate;
        }