Esempio n. 1
0
 public Callcenter Create(UserAdd model)
 {
     Callcenter data = null;
     using (var scope = new TransactionScope())
     {
         var user = new ApplicationUser { UserName = model.Username, Email = model.Email };
         var result = UserManager.Create(user, model.Password);
         if (result.Succeeded)
         {
             UserManager.AddToRole(UserManager.FindByName(user.UserName).Id, "Callcenter");
             data = context.Insert(new Callcenter
             {
                 Username = model.Username,
                 CallcenterId = model.Id,
                 SuperuserId = SignInManager.AuthenticationManager.User.Identity.GetUserId(),
                 PostCode = model.PostCode,
                 Phone = model.Phone,
                 NIN = model.NIN,
                 LastName = model.LastName,
                 FirstName = model.FirstName,
                 Email = model.Email,
                 Address = model.Address
             });
             context.Save();
             scope.Complete();
         }
     }
     return data;
 }
 public ActionResult Create(UserAdd model)
 {
     if (ModelState.IsValid)
     {
         callCenterRepo = new CallcenterRepo(context, HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>(), HttpContext.GetOwinContext().Get<ApplicationSignInManager>());
         callCenterRepo.Create(model);
         return RedirectToAction("Index");
     }
     return View(model);
 }
 public ActionResult Create(UserAdd model)
 {
     if (ModelState.IsValid)
     {
         superUserRepo = new SuperuserRepo(context, HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>());
         superUserRepo.Create(model);
         return RedirectToAction("Index");
     }
     return View(model);
 }