Beispiel #1
0
        public async Task <IActionResult> Index()
        {
            if (_helper.CorrectDomain())
            {
                if (HttpContext.User.Identity.IsAuthenticated)
                {
                    if (HttpContext.Request.Cookies["Identity.Domain"] != HttpContext.Items["domain"] as string)
                    {
                        return(RedirectToAction("LogOut"));
                    }
                    if (HttpContext.Items["domain"] as string == "default")
                    {
                        return(RedirectToAction("Index", "Admin"));
                    }
                    else
                    {
                        var idUser = _ut.GetUserId(HttpContext.User.Identity.Name);
                        _notificationTable.NotifyCloseDeadlineTasks(idUser);
                        if (idUser == 1)
                        {
                            _notificationTable.NotifyClosePaymentExpirationDate(_tt.GetTenantId(HttpContext.Items["domain"] as string));
                        }
                        var TenantPolicyResult = await _authorization.AuthorizeAsync(User, "TenantPolicy");

                        if (TenantPolicyResult.Succeeded)
                        {
                            return(RedirectToAction("Index", "HomePage"));
                        }
                        else
                        {
                            await SignInMgr.SignOutAsync();
                        }
                    }
                }
                var model = new IndexViewModel
                {
                    Domain         = HttpContext.Items["domain"] as string,
                    SignUpSelected = false,
                    SignIn         = new SignInForm(),
                    SignUp         = new SignUpForm()
                };
                return(View(model));
            }
            else
            {
                return(RedirectToAction("DomainError", "Home"));
            }
        }
Beispiel #2
0
        public IActionResult Index()
        {
            var model = new ServiceViewModel()
            {
                ServiceTenantOrder = _serviceOrderTable.GetNewestServiceOrderToTenantByTenantId(_tenantTable.GetTenantId(HttpContext.Items["domain"] as string)),
                Basic    = _serviceOrderTable.GetServiceById((int)Services.Basic),
                Pro      = _serviceOrderTable.GetServiceById((int)Services.Pro),
                Business = _serviceOrderTable.GetServiceById((int)Services.Business)
            };

            return(View(model));
        }
Beispiel #3
0
        public IActionResult Index()
        {
            var model = new ProfileViewModel
            {
                User = _userTable.GetUserWithSettingsById(_userTable.GetUserId(HttpContext.User.Identity.Name)),
                ChangePassowrdForm = new ChangePasswordForm(),
                IdService          = _serviceOrderTable.GetInUseServiceIdByTenantId(_tenantTable.GetTenantId(HttpContext.Items["domain"] as string)),
                ServiceTenantOrder = _serviceOrderTable.GetNewestServiceOrderToTenantByTenantId(_tenantTable.GetTenantId(HttpContext.Items["domain"] as string)),
                Basic    = _serviceOrderTable.GetServiceById((int)Services.Basic),
                Pro      = _serviceOrderTable.GetServiceById((int)Services.Pro),
                Business = _serviceOrderTable.GetServiceById((int)Services.Business)
            };

            return(View(model));
        }
Beispiel #4
0
        public IActionResult Index(int idProject)
        {
            var idUser = _userTable.GetUserId(HttpContext.User.Identity.Name);

            if (_projectTable.UserCanViewProject(idUser, idProject))
            {
                var project = _projectTable.GetProjectById(idProject);
                var model   = new ProjectViewModel()
                {
                    Project                 = project,
                    UserProjects            = _projectTable.GetUserProjectsByProjectId(idProject),
                    Tasks                   = _taskTable.GetTasksByProjectId(idProject).OrderByDescending(t => t.Created),
                    IdSignedUser            = idUser,
                    IdRoleSignedUserProject = _projectTable.GetRoleOfUser(idUser, idProject),
                    UsersOutOfProject       = new List <SelectListItem>(),
                    UserInProject           = new List <SelectListItem>(),
                    Priority                = new List <SelectListItem>(),
                    IdService               = _serviceOrderTable.GetInUseServiceIdByTenantId(_tenantTable.GetTenantId(HttpContext.Items["domain"] as string)),
                    SettingsColoring        = _userTable.GetSettingsbyUserId(idUser).Coloring == "1" ? true : false,
                    PageTitle               = project.Name,
                    PageDescription         = project.Description,
                    TaskForm                = new TaskForm()
                };
                foreach (var user in _userTable.GetUsersOutOfProjectByProjectId(idProject))
                {
                    var text = user.FirstName + " " + user.Surname + " - " + user.Email;
                    model.UsersOutOfProject.Add(new SelectListItem {
                        Text = text, Value = user.Id.ToString()
                    });
                }
                foreach (var user in _userTable.GetUsersInProjectByProjectId(idProject))
                {
                    var text = user.FirstName + " " + user.Surname + " - " + user.Email;
                    model.UserInProject.Add(new SelectListItem {
                        Text = text, Value = user.Id.ToString()
                    });
                }
                foreach (string name in Enum.GetNames(typeof(Priority)))
                {
                    model.Priority.Add(new SelectListItem {
                        Text = name, Value = name
                    });
                }
                return(View(model));
            }
            return(RedirectToAction("Index", "HomePage"));
        }
Beispiel #5
0
        public IActionResult Index()
        {
            if (HttpContext.Request.Cookies["Identity.Domain"] != HttpContext.Items["domain"] as string)
            {
                return(RedirectToAction("LogOut", "Home"));
            }
            var model = new HomePageViewModel
            {
                User           = _userTable.GetUserWithProjects(HttpContext.User.Identity.Name),
                ExistsProject  = false,
                IdService      = _serviceOrderTable.GetInUseServiceIdByTenantId(_tenantTable.GetTenantId(HttpContext.Items["domain"] as string)),
                SettingsCustom = _userTable.GetSettingsbyUserId(_userTable.GetUserId(HttpContext.User.Identity.Name)).CustomizeView == "1"
            };

            foreach (var p in model.User.UserProject)
            {
                if (p.IdRole == (int)Roles.ProjectUser || p.IdRole == (int)Roles.ProjectLeader)
                {
                    model.ExistsProject = true;
                    break;
                }
            }
            return(View(model));
        }
        protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, TenantPolicyRequirement requirement)
        {
            if (CorrectDomain())
            {
                if (CorrectUser() || _httpContext.Request.Path.Value.Contains("SignIn") || _httpContext.Request.Path.Value.Contains("SignUp"))
                {
                    var serviceOrder = _serviceOrderTable.GetNewestServiceOrderToTenantByTenantId(_tenantTable.GetTenantId(_httpContext.Items["domain"] as string));
                    if (serviceOrder.IdService == (int)Services.Basic)
                    {
                        context.Succeed(requirement);
                    }
                    else if (serviceOrder.IdPaymentNavigation.Paid.HasValue)
                    {
                        if ((serviceOrder.IdPaymentNavigation.Price == serviceOrder.IdServiceNavigation.Price &&
                             serviceOrder.IdPaymentNavigation.Paid.Value.AddDays(30) > DateTime.Now) || _httpContext.Request.Path.Value.Contains("Profile") || _httpContext.Request.Path.Value.Contains("Service"))
                        {
                            context.Succeed(requirement);
                        }
                    }
                }
            }

            return(Task.CompletedTask);
        }
Beispiel #7
0
        public IActionResult UserUseNotifications()
        {
            int  idService           = _serviceOrderTable.GetInUseServiceIdByTenantId(_tenantTable.GetTenantId(HttpContext.Items["domain"] as string));
            bool notificationSetting = _userTable.GetSettingsbyUserId(_userTable.GetUserId(HttpContext.User.Identity.Name)).Notifications == "1";

            if (idService != (int)Services.Basic && notificationSetting)
            {
                return(Json(true));
            }

            return(Json(false));
        }