public ActionResult Modifier_image_profil(HttpPostedFileBase file)
        {
            if (file != null)
            {
                prestataire pre = dbmetier.prestataires.Find(User.Identity.GetUserId());
                //get the bytes from the uploaded file
                byte[] data = GetBytesFromFile(file);
                pre.image_prestataire = data;
                dbmetier.SaveChanges();
            }

            return(RedirectToAction("Information_prstataire", "Prestataire"));
        }
Example #2
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    // await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
                    await this.UserManager.AddToRoleAsync(user.Id, model.Roles);

                    dbmetier = new market_appEntities();

                    if (model.Roles == "prestataire")
                    {
                        prestataire pres = new prestataire();
                        pres.libelle             = model.libelle;
                        pres.raison_social       = model.Raison_social;
                        pres.id_prestataire_user = user.Id;
                        pres.id_prestataire      = user.Id;
                        dbmetier.prestataires.Add(pres);
                        dbmetier.SaveChanges();
                    }
                    if (model.Roles == "responsable_marche")
                    {
                        Responsable_marché res = new Responsable_marché();
                        res.nom    = model.Nom;
                        res.prenom = model.Prenom;
                        res.id_responsable_user = user.Id;
                        res.id_responsable      = user.Id;
                        dbmetier.Responsable_marché.Add(res);
                        dbmetier.SaveChanges();
                    }
                    return(RedirectToAction("Register", "Account"));
                }
                ViewBag.Roles = new SelectList(db.Roles.ToList(), "Name", "Name");
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
 public ActionResult Create(Projet project)
 {
     try
     {
         dbmetier.Projets.Add(project);
         dbmetier.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult ajouteMission(int id_ordre, List <int> listmission, int id_marche)
        {
            if (User.Identity.GetUserId() == dbmetier.Marché.Where(a => a.id_marché == id_marche).Select(a => a.id_responsable_fk).FirstOrDefault())
            {
                Ordre_service ordre = dbmetier.Ordre_service.Find(id_ordre);

                foreach (var item in listmission)
                {
                    Mission mission = new Mission();
                    mission = dbmetier.Missions.Find(item);
                    mission.id_ordreservice_fk = ordre.id_ordre_service;
                }
                dbmetier.SaveChanges();
            }
            return(RedirectToAction("Dashboardresp", new { id_marche = id_marche }));
        }