public ActionResult Index()
        {
            User currentUser = brioContext.CurrentUser;

            if (currentUser.RoleId != (int)Brio.Models.Roles.Admin)
            {
                return(RedirectToAction("Index", "Project"));
            }

            InfoCard        currentUserInfoCard = infoCardRepository.GetUserInfoCard(brioContext.CurrentUser.ID);
            List <Division> divisions           = divisionRepository.GetCompanyDivisions(currentUserInfoCard.CompanyId).ToList();

            SelectList divisions_sel = new SelectList(divisions, "ID", "Name");

            ViewBag.Divisions = divisions_sel;

            ViewBag.Roles = roleRepository.GetAll().ToList();


            ViewBag.Admins         = infoCardRepository.GetInfoCardsByRole(Roles.Admin, brioContext.CurrentUser.CompanyId);
            ViewBag.Clients        = infoCardRepository.GetInfoCardsByRole(Roles.Client, brioContext.CurrentUser.CompanyId);
            ViewBag.Employees      = infoCardRepository.GetInfoCardsByRole(Roles.Employee, brioContext.CurrentUser.CompanyId);
            ViewBag.ProjectManager = infoCardRepository.GetInfoCardsByRole(Roles.ProjectManager, brioContext.CurrentUser.CompanyId);

            ViewBag.IsSuccess     = TempData["IsSuccess"];
            ViewBag.Message       = TempData["Message"];
            ViewBag.UpdateAccount = TempData["UpdateAccount"] != null ? TempData["UpdateAccount"] : new EditPortalAccount();

            if (TempData["Account"] != null)
            {
                return(View(TempData["Account"] as CreatePortalAccount));
            }
            return(View());
        }
        public JsonResult GetProject(int id)
        {
            Project project = projectRepository.GetById(id);

            List <ProjectDocument>    documents    = projectDocumentRepository.GetProjectDocuments(id).ToList();
            List <ProjectDocumentDTO> documentsDTO = new List <ProjectDocumentDTO>();


            foreach (ProjectDocument pd in documents)
            {
                documentsDTO.Add(new ProjectDocumentDTO
                {
                    DocumentPath  = pd.DocumentPath,
                    DocumentTitle = pd.DocumentTitle,
                    Id            = pd.ID,
                    ProjectId     = pd.ProjectId.HasValue ? pd.ProjectId.Value : 0,
                    UploadDate    = pd.UploadDate
                });
            }

            ProjectDTO projectTransferObj = new ProjectDTO
            {
                Id                = project.ID,
                CompanyId         = infoCardRepository.GetUserInfoCard(brioContext.CurrentUser.ID).CompanyId,
                CreateDate        = DateTime.Now,
                Description       = project.Description,
                EndDate           = project.EndDate.HasValue ? project.EndDate.Value : DateTime.MinValue,
                ResponsibleUserId = project.ResponsibleUserId,
                StartDate         = project.StartDate.HasValue ? project.StartDate.Value : DateTime.MinValue,
                Tile              = project.Tile,
                Documents         = documentsDTO
            };


            if (project != null)
            {
                return(Json(ResponseProcessing.Success(projectTransferObj, "Проект успешно извлечен.")));
            }
            else
            {
                return(Json(ResponseProcessing.Error(String.Format("Проекта с идентификатором {0} не существует.", id))));
            }
        }
        public ActionResult Login(LoginUser model, string ReturnUrl)
        {
            string message;

            if (ModelState.IsValid)
            {
                var user = _userRepository.GetByEmail(model.Email);

                if (user != null)
                {
                    var userInfo = _infoCardRepository.GetUserInfoCard(user.ID);
                    if (userInfo != null)
                    {
                        _brioContext.Auth.Login(model.Email, model.Password, model.RememberMe);

                        if (Url.IsLocalUrl(ReturnUrl))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else
                    {
                        message = "Имя пользователя или пароль является не корректным";
                    }
                }
                else
                {
                    message = "Имя пользователя или пароль является не корректным";
                }
            }
            else
            {
                message = "Не заполнены все поля. Пожалуйста заполните все поля и повторите попытку";
            }

            ViewBag.IsSuccess = false;
            ViewBag.Message   = message;

            return(View(model));
        }