Esempio n. 1
0
 public void Configure(IServerRoutingTable serverRoutingTable)
 {
     using (var context = new TorshiaDbContext())
     {
         context.Database.EnsureCreated();
     }
 }
Esempio n. 2
0
        public void AddTaskSectors(string sectorCustomers, string sectorMarketing, string sectorFinances, string sectorInternal, string sectorManagement, int taskId)
        {
            var sectors = new List <string>
            {
                sectorCustomers,
                sectorMarketing,
                sectorFinances,
                sectorInternal,
                sectorManagement
            };

            using (var db = new TorshiaDbContext())
            {
                foreach (var sectorString in sectors)
                {
                    if (Enum.TryParse <Sector>(sectorString, true, out var sector))
                    {
                        var taskSector = new TaskSector
                        {
                            TaskId = taskId,
                            Sector = sector
                        };

                        db.TaskSectors.Add(taskSector);
                        db.SaveChanges();
                    }
                }
            }
        }
Esempio n. 3
0
 public bool AreThereUsers()
 {
     using (var db = new TorshiaDbContext())
     {
         return(db.Users.Any());
     }
 }
Esempio n. 4
0
 public void Configure(IServerRoutingTable serverRoutingTable)
 {
     // Once on start
     using (var db = new TorshiaDbContext())
     {
         db.Database.EnsureCreated();
     }
 }
Esempio n. 5
0
        public Task GetTask(int taskId)
        {
            using (var db = new TorshiaDbContext())
            {
                var task = db.Tasks.FirstOrDefault(t => t.Id == taskId);

                return(task);
            }
        }
Esempio n. 6
0
        public List <Task> GetAllNonReportedTasks()
        {
            using (var db = new TorshiaDbContext())
            {
                var tasks = db.Tasks
                            .Where(t => t.IsReported == false)
                            .ToList();

                return(tasks);
            }
        }
        public List <Report> GetAllReports()
        {
            using (var db = new TorshiaDbContext())
            {
                var reports = db.Reports
                              .Include(r => r.Task)
                              .ToList();

                return(reports);
            }
        }
 public Report GetReport(int id)
 {
     using (var db = new TorshiaDbContext())
     {
         return(db.Reports
                .Where(r => r.Id == id)
                .Include(r => r.Task)
                .Include(r => r.Reporter)
                .FirstOrDefault());
     }
 }
Esempio n. 9
0
        public int GetTaskLevel(int taskId)
        {
            using (var db = new TorshiaDbContext())
            {
                var level = db.TaskSectors
                            .Where(t => t.TaskId == taskId)
                            .Count();

                return(level);
            }
        }
Esempio n. 10
0
        public void ChangeIsReported(int taskId)
        {
            using (var db = new TorshiaDbContext())
            {
                var task = db.Tasks.FirstOrDefault(t => t.Id == taskId);

                task.IsReported = true;

                db.SaveChanges();
            }
        }
Esempio n. 11
0
        public User GetUser(string username, string password)
        {
            using (var db = new TorshiaDbContext())
            {
                var user = db
                           .Users
                           .FirstOrDefault(u => u.Username == username && u.Password == password);

                return(user);
            }
        }
Esempio n. 12
0
        public User GetUser(string username)
        {
            using (var db = new TorshiaDbContext())
            {
                var user = db
                           .Users
                           .FirstOrDefault(u => u.Username == username);

                return(user);
            }
        }
Esempio n. 13
0
        public string GetAllAffectedSectors(int taskId)
        {
            using (var db = new TorshiaDbContext())
            {
                var taskSectors = db.TaskSectors
                                  .Where(ts => ts.TaskId == taskId)
                                  .Select(ts => ts.Sector.ToString())
                                  .ToList();

                return(string.Join(", ", taskSectors));
            }
        }
Esempio n. 14
0
 public void Configure(IServerRoutingTable serverRoutingTable, RouteSettings routeSettings)
 {
     using (var context = new TorshiaDbContext())
     {
         bool isCreated = context.Database.EnsureCreated();
         if (isCreated)
         {
             Seeder.SeedRoles();
             Seeder.SeedAdmin();
         }
     }
 }
        public void AddReport(DateTime date, Status status, int taskId, int userId)
        {
            using (var db = new TorshiaDbContext())
            {
                var reporter = new Report
                {
                    ReportedOn = date,
                    Status     = status,
                    TaskId     = taskId,
                    ReporterId = userId
                };

                db.Reports.Add(reporter);
                db.SaveChanges();
            }
        }
Esempio n. 16
0
        public void AddUser(string username, string password, string email, Role role)
        {
            using (var db = new TorshiaDbContext())
            {
                var user = new User
                {
                    Username = username,
                    Password = password,
                    Email    = email,
                    Role     = role
                };

                db.Users.Add(user);
                db.SaveChanges();
            }
        }
Esempio n. 17
0
        public Task AddTask(string title, DateTime dueDate, string description, string participants)
        {
            using (var db = new TorshiaDbContext())
            {
                var task = new Task
                {
                    Title        = title,
                    DueDate      = dueDate,
                    Description  = description,
                    Participants = participants
                };

                db.Tasks.Add(task);
                db.SaveChanges();

                return(task);
            }
        }
Esempio n. 18
0
        private void SeedDatabase()
        {
            using (var context = new TorshiaDbContext())
            {
                context.Database.EnsureCreated();

                context.UserRoles.Add(new UserRole {
                    Name = "User"
                });
                context.UserRoles.Add(new UserRole {
                    Name = "Admin"
                });

                context.Sectors.Add(new Sector {
                    Name = "Customers"
                });
                context.Sectors.Add(new Sector {
                    Name = "Marketing"
                });
                context.Sectors.Add(new Sector {
                    Name = "Finances"
                });
                context.Sectors.Add(new Sector {
                    Name = "Internal"
                });
                context.Sectors.Add(new Sector {
                    Name = "Management"
                });

                context.ReportStatuses.Add(new ReportStatus {
                    Status = "Completed"
                });
                context.ReportStatuses.Add(new ReportStatus {
                    Status = "Archived"
                });

                context.SaveChanges();
            }
        }
Esempio n. 19
0
 public ReportService(TorshiaDbContext db)
 {
     this.db = db;
 }
 public BaseController()
 {
     this.db = new TorshiaDbContext();
 }
Esempio n. 21
0
 public TasksService(TorshiaDbContext context)
 {
     this.context = context;
 }
Esempio n. 22
0
 protected BaseController()
 {
     this.hashService = new HashService(new ConsoleLogger());
     this.DbContext   = new TorshiaDbContext();
 }
 public ReportsService(TorshiaDbContext context)
 {
     this.context = context;
 }
Esempio n. 24
0
 protected BaseController()
 {
     DbContext = new TorshiaDbContext();
 }
Esempio n. 25
0
 public ReportsService(TorshiaDbContext db)
     : base(db)
 {
 }
Esempio n. 26
0
 public UsersService(TorshiaDbContext db)
     : base(db)
 {
 }
Esempio n. 27
0
 public BaseController()
 {
     this.ErrorMessage = "";
     this.context      = new TorshiaDbContext();
 }
Esempio n. 28
0
 public TasksService(TorshiaDbContext db, IUsersService usersServices)
     : base(db)
 {
     this.usersServices = usersServices;
 }
 public UsersService(TorshiaDbContext context)
 {
     this.context = context;
 }
 public TasksService(TorshiaDbContext context, IReportsService reportsService)
     : base(context)
 {
     this.reportsService = reportsService;
 }