Exemple #1
0
        static void Main(string[] args)
        {
            LevioMapCtx lev = new LevioMapCtx();


            lev.SaveChanges();
            Console.WriteLine("Base Created with succes ");
            Console.ReadKey();
        }
Exemple #2
0
 public UnitOfWork(IDatabaseFactory dbFactory)
 {
     this.dbFactory = dbFactory;
     dataContext    = dbFactory.DataContext;
 }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            LevioMapCtx ct = new LevioMapCtx();

            if (ModelState.IsValid)
            {
                IdentityResult result;

                // Switch on Selected Account type
                switch (model.AccountType)
                {
                // Volunteer Account type selected:
                case EAccountType.Client:
                {
                    // create new volunteer and map form values to the instance
                    Client v = new Client {
                        UserName = model.Email, Email = model.Email, FirstName = model.FirstName
                    };
                    v.EmailConfirmed = true;
                    v.SecurityStamp  = null;
                    result           = await UserManager.CreateAsync(v, model.Password);

                    // Add User role to the new User
                    if (result.Succeeded)
                    {
                        // UserManager.AddToRole(v.Id, EAccountType.Patient.ToString());
                        await SignInManager.SignInAsync(v, isPersistent : false, rememberBrowser : false);

                        // Email confirmation here

                        return(RedirectToAction("Index", "Home"));
                    }
                    AddErrors(result);
                }
                break;

                // Ressource Account type selected:
                case EAccountType.Ressource:
                {
                    Resource ngo = new Resource {
                        UserName = model.Email, Email = model.Email, FirstName = model.FirstName                                  /*, InterMandateId = 1 */
                    };
                    result = await UserManager.CreateAsync(ngo, model.Password);

                    ngo.EmailConfirmed = true;

                    //ngo.SecurityStamp = null;
                    // Add Ngo role to the new User
                    if (result.Succeeded)
                    {
                        //     UserManager.AddToRole(ngo.Id, EAccountType.Doctor.ToString());
                        await SignInManager.SignInAsync(ngo, isPersistent : false, rememberBrowser : false);

                        return(RedirectToAction("Index", "Home"));
                    }
                    // AddErrors(result);
                }
                break;
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
 public DatabaseFactory()
 {
     dataContext = new LevioMapCtx();
 }