Пример #1
0
        public async Task <IActionResult> Edit(int?id, [FromServices] IRepositoryHandler <Employees> repoEmployee)
        {
            if (id != null)
            {
                var task = await repositoryHandler.GetEntryByIDAsync(id.Value, u => u.Reporter.FullName.Equals(User.Identity.Name) ||
                                                                     u.Assignee.FullName.Equals(User.Identity.Name) ||
                                                                     User.IsInRole(EmployeeRole.Admin.ToString()));

                if (task is null)
                {
                    return(new ContentResult {
                        StatusCode = 403, Content = "Forbidden", ContentType = "text/html"
                    });
                }

                var employeesList = await repoEmployee.GetAllEntriesAsync();

                ViewBag.IsAdmin    = User.IsInRole(EmployeeRole.Admin.ToString());
                ViewBag.IsReporter = (await repoEmployee.GetFirstEntityAsync(u => u.FullName.Equals(User.Identity.Name))).Id.Equals(task.ReporterId);

                var model = new TaskEditModelHybrid
                {
                    Task         = task,
                    AssigneeList = new SelectList(employeesList, "Id", "FullName", task.AssigneeId),
                    ReporterList = new SelectList(employeesList, "Id", "FullName", task.ReporterId),
                    PriorityList = TaskEnum.PriorityList((int)task.Priority),
                    StatusList   = TaskEnum.StatusList((int)task.Status),
                };

                return(View(model));
            }
            return(RedirectToAction("Index"));
        }
        public StaffController(IRepositoryHandler <Employees> handler)
        {
            repositoryHandler = handler;

            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <StaffAddModelHybrid, Employees>()
                .ForMember(to => to.Id, from => from.Ignore())
                .ForMember(to => to.ShortName, from => from.MapFrom(m => m.ShortName))
                .ForMember(to => to.FullName, from => from.MapFrom(m => m.FullName))
                .ForMember(to => to.Email, from => from.MapFrom(m => m.Email))
                .ForMember(to => to.Role, from => from.Ignore())
                .ForMember(to => to.RoleId, from => from.Ignore())
                .ForMember(to => to.Password, from => from.Ignore())
                .ForMember(to => to.AssignedQTasks, from => from.Ignore())
                .ForMember(to => to.ReporteredQTasks, from => from.Ignore());

                cfg.CreateMap <StaffEditModelHybrid, Employees>()
                .ForMember(to => to.Id, from => from.MapFrom(m => m.StaffId))
                .ForMember(to => to.ShortName, from => from.MapFrom(m => m.ShortName))
                .ForMember(to => to.FullName, from => from.MapFrom(m => m.FullName))
                .ForMember(to => to.Email, from => from.MapFrom(m => m.Email))
                .ForMember(to => to.Role, from => from.Ignore())
                .ForMember(to => to.RoleId, from => from.Ignore())
                .ForMember(to => to.Password, from => from.Ignore())
                .ForMember(to => to.AssignedQTasks, from => from.Ignore())
                .ForMember(to => to.ReporteredQTasks, from => from.Ignore());
            });

            // TODO: remove following statement if not developer mode
            configuration.AssertConfigurationIsValid();
            mapper = configuration.CreateMapper();
        }
Пример #3
0
        public TasksController(IRepositoryHandler <QTask> handler)
        {
            repositoryHandler = handler;

            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <TaskAddModelHybrid, QTask>()
                .ForMember(to => to.Priority, from => from.MapFrom(m => (TaskPriority)m.Priority))
                .ForMember(to => to.Name, from => from.MapFrom(m => m.Title))
                .ForMember(to => to.Assignee, from => from.Ignore())
                .ForMember(to => to.Reporter, from => from.Ignore())
                .ForMember(to => to.Status, from => from.Ignore())
                .ForMember(to => to.Id, from => from.Ignore());

                cfg.CreateMap <TaskEditModelHybrid, QTask>()
                .ForMember(to => to.Priority, from => from.MapFrom(m => m.Priority.HasValue ? (TaskPriority)m.Priority : TaskPriority.None))
                .ForMember(to => to.Status, from => from.MapFrom(m => m.Status.HasValue ? (QTaskStatus)m.Status : QTaskStatus.None))
                .ForMember(to => to.Name, from => from.MapFrom(m => m.Title))
                .ForMember(to => to.Id, from => from.MapFrom(m => m.TaskId))
                .ForMember(to => to.Assignee, from => from.Ignore())
                .ForMember(to => to.Reporter, from => from.Ignore());
            });

            // TODO: remove following statement if not developer mode
            configuration.AssertConfigurationIsValid();
            mapper = configuration.CreateMapper();
        }
Пример #4
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app, IRepositoryHandler factory, ISettingsBusiness settingsBusiness)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            //factory.RegisterApplicationDbContext(app);
            //factory.RegisterApplicationUserManager(app);
            //factory.RegisterApplicationSignInManager(app);
            factory.Register(app);

            //app.CreatePerOwinContext()

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = factory.OnValidateIdentity(),
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            var googleSetting = settingsBusiness.GetGoogleAuthSetting();

            if (!(string.IsNullOrEmpty(googleSetting.ClientId) || string.IsNullOrEmpty(googleSetting.ClientSecret)))
            {
                app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
                {
                    ClientId     = googleSetting.ClientId,
                    ClientSecret = googleSetting.ClientSecret,
                });
            }
        }
 public DocumentTemplateController()
 {
     _templatesHandler =
         new DocumentTemplatesRepositoryHandler();
     _positionsHandler =
         new PositionsRepositoryHandler();
     _usersRepositoryHandler =
         new UsersRepositoryHandler();
     _typeRepositoryHandler =
         new DocumentTypesRepositoryHandler();
 }
        public async Task <IActionResult> Add(StaffAddModelHybrid model, [FromServices] IRepositoryHandler <Role> repoRole)
        {
            if (ModelState.IsValid)
            {
                var employee = mapper.Map <Employees>(model);
                employee.Role = await repoRole.GetFirstEntityAsync(r => r.Name == (EmployeeRole)model.Role);

                repositoryHandler.Create(employee);
            }
            return(RedirectToAction("Index"));
        }
Пример #7
0
        public async Task <IActionResult> Add([FromServices] IRepositoryHandler <Employees> repoEmployee)
        {
            ViewBag.IsAdmin = User.IsInRole(EmployeeRole.Admin.ToString());
            var employeesList = new SelectList(await repoEmployee.GetAllEntriesAsync(), "Id", "FullName");
            var model         = new TaskAddModelHybrid
            {
                ReporterId   = (await repoEmployee.GetFirstEntityAsync(u => u.FullName.Equals(User.Identity.Name))).Id,
                AssigneeList = employeesList,
                ReporterList = employeesList,
                PriorityList = TaskEnum.PriorityList()
            };

            return(View(model));
        }
Пример #8
0
 public UserService(IRepositoryHandler <IUserDomainEntity> handler) : base(handler)
 {
 }
Пример #9
0
 public CommentService(IRepositoryHandler <ICommentDomainEntity> handler) : base(handler)
 {
 }
Пример #10
0
 public PositionController()
 {
     _positionsHandler = new PositionsRepositoryHandler();
 }
 public PositionController()
 {
     _positionsHandler = new PositionsRepositoryHandler();
 }
Пример #12
0
 public AccountRepository(IRepositoryHandler repositoryHandler)
 {
     _repositoryHandler = repositoryHandler;
 }
Пример #13
0
 public UserController()
 {
     _usersHandler = new UsersRepositoryHandler();
     _positionsHandler = new PositionsRepositoryHandler();
     _rolesHandler = new RolesRepositoryHandler();
 }
Пример #14
0
 public RoleController()
 {
     _rolesHandler = new RolesRepositoryHandler();
 }
Пример #15
0
 public RoleController()
 {
     _rolesHandler = new RolesRepositoryHandler();
 }
Пример #16
0
 protected GenericService(IRepositoryHandler <T> handler)
 {
     Handler = handler;
 }
Пример #17
0
 public UserController()
 {
     _usersHandler     = new UsersRepositoryHandler();
     _positionsHandler = new PositionsRepositoryHandler();
     _rolesHandler     = new RolesRepositoryHandler();
 }
 public void SetRepositoryHandler(IRepositoryHandler repositoryHandler)
 {
     m_RepositoryHandler = repositoryHandler;
 }
 public DocumentTypeController()
 {
     _typesHandler = new DocumentTypesRepositoryHandler();
 }
Пример #20
0
 public ServiceHandler()
 {
     repositoryHandler = RepositoryFactory.RepositoryFactory.GetSQLServerImplementation();
 }
Пример #21
0
 public DocumentTypeController()
 {
     _typesHandler = new DocumentTypesRepositoryHandler();
 }
 public AccountController(IRepositoryHandler <Employees> handler)
 {
     repositoryHandler = handler;
 }
Пример #23
0
 public DiaryService(IRepositoryHandler <IDiaryDomainEntity> handler) : base(handler)
 {
 }