public ActionResult Edit(Domain.Entity.Mandat mandat, int id, FormCollection collection)
        {
            MAPContext mcx = new MAPContext();

            // TODO: Add update logic here
            try {
                Domain.Entity.Mandat x = mcx.Mandats.Single(a => a.idMandat == id);
                // Domain.Entity.Mandat x = new Domain.Entity.Mandat();
                x.date_debut = mandat.date_debut;

                x.date_fin = mandat.date_fin;
                //x.idProject = mandat.idProject;
                //x.IdRessource = mandat.IdRessource;
                x.NomMandat = mandat.NomMandat;
                mcx.Mandats.Attach(x);


                mcx.SaveChanges();
                //ms.Update(x);
                //ms.Commit();
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                return(RedirectToAction("Edit", new { id = id, saveChangesError = true }));
            }

            return(RedirectToAction("Create", "Email"));
        }
        // GET: Mandat/Details/5
        public ActionResult Details(int id)
        {
            MAPContext mcd = new MAPContext();

            Domain.Entity.Mandat qs = mcd.Mandats.Find(id);

            return(View(qs));
        }
        private void AddUsersAndRoles()
        {
            MAPContext context     = new MAPContext();
            var        roleManager = new RoleManager <CustomRole, int>(new RoleStore <CustomRole, int, CustomUserRole>(context));
            var        UserManager = new UserManager <Users, int>(new UserStore <Users, CustomRole, int, CustomUserLogin, CustomUserRole, CustomUserClaim>(context));


            // In Startup iam creating first Admin Role and creating a default Admin User
            var role = new CustomRole();

            if (!roleManager.RoleExists("Client"))
            {
                role.Name = "Client";
                roleManager.Create(role);
            }

            if (!roleManager.RoleExists("Ressource"))
            {
                role.Name = "Ressource";
                roleManager.Create(role);
            }

            if (!roleManager.RoleExists("Applicant"))
            {
                role.Name = "Applicant";
                roleManager.Create(role);
            }

            if (!roleManager.RoleExists("Responsable"))
            {
                role.Name = "Responsable";
                roleManager.Create(role);
            }

            if (!roleManager.RoleExists("SuperAdmin"))
            {
                role.Name = "SuperAdmin";
                roleManager.Create(role);
            }
            if (UserManager.FindByName("SuperAdmin") == null)
            {
                var user = new Users
                {
                    UserName = "******",

                    Email    = "*****@*****.**",
                    Password = "******"
                };
                var Password = "******";
                var chkUser  = UserManager.Create(user, Password);
                if (chkUser.Succeeded)
                {
                    var result1 = UserManager.AddToRole(user.Id, "SuperAdmin")
                    ;
                }
            }
        }
Пример #4
0
 public JsonResult GetRessources()
 {
     using (MAPContext dc = new MAPContext())
     {
         var ressource = dc.Ressource.ToList();
         return(new JsonResult {
             Data = ressource, JsonRequestBehavior = JsonRequestBehavior.AllowGet
         });
     }
 }
Пример #5
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new Users {
                    UserName = model.Email, Email = model.Email, Password = model.Password
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    if (model.Roles == "Client")
                    {
                        UserManager.AddToRole(user.Id, "Client");
                        MAPContext ctx = new MAPContext();

                        //ctx.Medecin.Add(new Medecin  { UserName ="******" });
                        ctx.Client.Add(new Domain.Entity.Client {
                            UserName = "******"
                        });
                    }
                    else
                    if (model.Roles == "Ressource")
                    {
                        UserManager.AddToRole(user.Id, "Ressource");
                    }
                    else if (model.Roles == "Applicant")
                    {
                        UserManager.AddToRole(user.Id, "Applicant");
                        //Applicant app = new Applicant();
                        //app.Email = model.Email;
                        //ApplicantService aps = new ApplicantService();
                        //aps.Add(app);
                        //aps.Commit();
                    }



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

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

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
 public ActionResult Delete(int id, FormCollection collection)
 {
     MAPContext mc = new MAPContext();
     {
         try
         {
             Domain.Entity.Mandat mandat = mc.Mandats.Find(id);
             mc.Mandats.Remove(mandat);
             mc.SaveChanges();
             //  ms.Delete(mandat);
             // ms.Commit();
         }
         catch (DataException /* dex */)
         {
             //Log the error (uncomment dex variable name and add a line here to write a log.
             return(RedirectToAction("Delete", new { id = id, saveChangesError = true }));
         }
         return(RedirectToAction("Index"));
     }
 }
        //{
        //    try
        //    {
        //        Domain.Entity.Mandat m = new Domain.Entity.Mandat();
        //        m = ms.GetAll().Where(e => e.id == id).First();
        //        m.archive = true;
        //        ms.Delete(m);
        //        ms.Commit();

        //        return RedirectToAction("Index");
        //    }
        //    catch (DataException/* dex */)
        //    {
        //        //Log the error (uncomment dex variable name and add a line here to write a log.
        //        return RedirectToAction("Delete", new { id = id, saveChangesError = true });
        //    }
        //    return RedirectToAction("Index");
        //}
        public ActionResult Calculer(int id)
        {
            MAPContext mcc = new MAPContext();

            Domain.Entity.Mandat qs = mcc.Mandats.Find(id);
            //Domain.Entity.Mandat mandat = ms.GetById(id);
            List <Domain.Entity.Ressource> ressources = new List <Domain.Entity.Ressource>();

            ressources = rs.GetAll().ToList();
            String name = null;


            foreach (Domain.Entity.Ressource r in ressources)
            {
                if (r.idRessource == qs.IdRessource)
                {
                    name = r.FirstName;
                }
            }
            ViewBag.name = name;


            return(View());
        }
 public AccountController()
 {
     db = new MAPContext();
 }
 public DatabaseFactory()
 {
     dataContext = new MAPContext();
 }
Пример #10
0
 public UnitOfWork(IDatabaseFactory dbFactory)
 {
     this.dbFactory = dbFactory;
     dataContext    = dbFactory.DataContext;
 }
Пример #11
0
 public ActionResult HomeClient()
 {
     db = new MAPContext();
     return(View());
 }
Пример #12
0
 public ActionResult HomeRessource()
 {
     db = new MAPContext();
     return(View());
 }
Пример #13
0
 public ActionResult Register()
 {
     db            = new MAPContext();
     ViewBag.Roles = new SelectList(db.Roles.Where(a => !a.Name.Contains("SuperAdmin")), "Name", "Name");
     return(View());
 }