Пример #1
0
        public async Task<ActionResult> Register(RegisterViewModel model, string Rol,string area)
        {
            EntitiesLogueo db;
            if (ModelState.IsValid)
            {
                db = new EntitiesLogueo();
                var user = new ApplicationUser { UserName = model.UserName, Email = model.Email ,PhoneNumber = area };
                IdentityUserRole iur = new IdentityUserRole();
                iur.RoleId = Rol;
                iur.UserId = user.Id;
                user.Roles.Add(iur);
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    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);
            }

            db = new EntitiesLogueo();
            ViewBag.Rol = new SelectList(db.AspNetRoles, "Id", "Name");
            GProyEntities bd = new GProyEntities();
            ViewBag.area = new SelectList(bd.Area.Select(a => a.name).ToList());
            // If we got this far, something failed, redisplay form
            return View(model);
        }
Пример #2
0
        // GET: Projects
        public ActionResult Index(int? idp, int? idcliente)
        {
            if (!User.Identity.IsAuthenticated)//Temporal soluction until a find more information
            {
                return RedirectToAction("Index", "Home");

            }

            if (idcliente != null)
            {
                if (!User.IsInRole("Administrador") && !User.IsInRole("Consultor"))
                {
                    EntitiesLogueo el = new EntitiesLogueo();
                    AspNetUsers u = el.AspNetUsers.Find(User.Identity.GetUserId());
                    var project = db.Project.Include(p => p.Client).Where( p => p.Area.name == u.PhoneNumber && p.clientId==idcliente);
                    return View(project.ToList());
                }
                else
                {
                    var project = db.Project.Include(p => p.Client).Where(c => c.clientId == idcliente);
                    return View(project.ToList());
                }

            }
            if (idp == null)
            {
                if (!User.IsInRole("Administrador") && !User.IsInRole("Consultor"))
                {
                    EntitiesLogueo el = new EntitiesLogueo();
                    AspNetUsers u = el.AspNetUsers.Find(User.Identity.GetUserId());
                    var project = db.Project.Include(p => p.Client).Where(p=> p.Area.name == u.PhoneNumber);
                    return View(project.ToList());
                }
                else
                {
                    var project = db.Project.Include(p => p.Client);
                    return View(project.ToList());
                }

            }
            else
            {
                var project = db.Project.Include(p => p.Client).Where(p => p.projectId == idp);
                return View(project.ToList());

            }
        }
Пример #3
0
        public ActionResult Register()
        {

            EntitiesLogueo db = new EntitiesLogueo();
            ViewBag.Rol = new SelectList(db.AspNetRoles, "Id", "Name");
            GProyEntities bd = new GProyEntities();
            ViewBag.area= new SelectList(bd.Area.Select(a => a.name).ToList());
            return View();
        }
Пример #4
0
        // GET: Projects/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            Project project = db.Project.Find(id);
            if (!User.IsInRole("Administrador") && !User.IsInRole("Consultor"))
            {
                EntitiesLogueo el = new EntitiesLogueo();
                AspNetUsers u = el.AspNetUsers.Find(User.Identity.GetUserId());
                if (u.PhoneNumber != project.Area.name)
                {
                    return HttpNotFound();
                }
            }
            if (project == null)
            {
                return HttpNotFound();
            }
            ViewBag.areaId = new SelectList(db.Area, "areaId", "name", project.areaId);
            ViewBag.clientId = project.Client;
            ViewBag.productId = new SelectList(db.Product, "productId", "name", project.productId);
            ViewBag.idProduct = project.Product;
            ProjectState state = GetEstado(id);
            ViewBag.state = state;

            return View(project);
        }