public void Configure(IServerRoutingTable serverRoutingTable) { using (var context = new TorshiaDbContext()) { context.Database.EnsureCreated(); } }
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(); } } } }
public bool AreThereUsers() { using (var db = new TorshiaDbContext()) { return(db.Users.Any()); } }
public void Configure(IServerRoutingTable serverRoutingTable) { // Once on start using (var db = new TorshiaDbContext()) { db.Database.EnsureCreated(); } }
public Task GetTask(int taskId) { using (var db = new TorshiaDbContext()) { var task = db.Tasks.FirstOrDefault(t => t.Id == taskId); return(task); } }
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()); } }
public int GetTaskLevel(int taskId) { using (var db = new TorshiaDbContext()) { var level = db.TaskSectors .Where(t => t.TaskId == taskId) .Count(); return(level); } }
public void ChangeIsReported(int taskId) { using (var db = new TorshiaDbContext()) { var task = db.Tasks.FirstOrDefault(t => t.Id == taskId); task.IsReported = true; db.SaveChanges(); } }
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); } }
public User GetUser(string username) { using (var db = new TorshiaDbContext()) { var user = db .Users .FirstOrDefault(u => u.Username == username); return(user); } }
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)); } }
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(); } }
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(); } }
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); } }
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(); } }
public ReportService(TorshiaDbContext db) { this.db = db; }
public BaseController() { this.db = new TorshiaDbContext(); }
public TasksService(TorshiaDbContext context) { this.context = context; }
protected BaseController() { this.hashService = new HashService(new ConsoleLogger()); this.DbContext = new TorshiaDbContext(); }
public ReportsService(TorshiaDbContext context) { this.context = context; }
protected BaseController() { DbContext = new TorshiaDbContext(); }
public ReportsService(TorshiaDbContext db) : base(db) { }
public UsersService(TorshiaDbContext db) : base(db) { }
public BaseController() { this.ErrorMessage = ""; this.context = new TorshiaDbContext(); }
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; }