public bool RegisterUser(RegisterVM reg) { var success = false; using (var db = new ManagementToolEntities()) { var resp = new UsersRepository(db); bool emailExist = resp.AccountExist(reg.Email); if (!emailExist) { var regUser = new User { Email = reg.Email.Trim().ToLower(), FirstName = reg.FirstName, LastName = reg.LastName, Password = reg.Password, CompanyId = reg.CompanyId, Role = Roles.Employee.ToString() }; resp.Insert(regUser); success = db.SaveChanges() > 0; } } return(success); }
public bool CreateTask(TaskVM model) { bool success = false; using (var db = new ManagementToolEntities()) { var resp = new TaskRepository(db); var task = new DBModels.Task { Title = model.Title, Description = model.Description, DueDate = DateTime.Parse(model.DueDate), Status = model.Status.ToString(), ProjectId = model.ProjectId, ExpendedHours = model.TaskHours, Category = model.Category, AssignedTo = model.Developer }; resp.Insert(task); success = db.SaveChanges() > 0; } return(success); }
public List <ProjectVM> GetAllCompanyProjects(int companyId) { var projects = new List <ProjectVM>(); var transformer = new ProjectTransformer(); using (var db = new ManagementToolEntities()) { var resp = new ProjectRepository(db); IEnumerable <Project> dbProjects = resp.Get(proj => proj.CompanyId == companyId); projects = transformer.Transform(dbProjects); } return(projects); }
public List <TaskVM> GetAllTasks(int projectId) { var tasks = new List <TaskVM>(); var transformer = new TaskTransformer(); using (var db = new ManagementToolEntities()) { var resp = new TaskRepository(db); IEnumerable <DBModels.Task> dbtasks = resp.Get(t => t.ProjectId == projectId); tasks = transformer.Transform(dbtasks); } return(tasks); }
public CSUser GetUser(string email) { CSUser user = null; using (var db = new ManagementToolEntities()) { var resp = new UsersRepository(db); var dbUser = resp.GetFirstOrDefault(u => u.Email.Trim().ToLower() == email.Trim().ToLower()); UserTransformer transformer = new UserTransformer(); user = transformer.Transform(dbUser); } return(user); }
public List <RiskVM> GetProjectRisks(int projectId) { var model = new List <RiskVM>(); var transformer = new RiskTransformer(); using (var db = new ManagementToolEntities()) { var resp = new RiskRepository(db); IEnumerable <DBModels.Risk> risks = resp.Get(r => r.ProjectId == projectId); model = transformer.Transform(risks); } return(model); }
public TaskVM GetTask(int id) { var model = new TaskVM(); var transformer = new TaskTransformer(); using (var db = new ManagementToolEntities()) { var resp = new TaskRepository(db); DBModels.Task task = resp.GetFirstOrDefault(t => t.ProjectId == id); model = transformer.Transform(task); } return(model); }
public RequirementVM GetRequirement(int requirementId) { var model = new RequirementVM(); var transformer = new RequirementTransformer(); using (var db = new ManagementToolEntities()) { var resp = new RequirementRepository(db); var requirement = resp.GetFirstOrDefault(r => r.RequirementId == requirementId); model = transformer.Transform(requirement); } return(model); }
public ProjectVM GetProject(int id) { var model = new ProjectVM(); var transformer = new ProjectTransformer(); using (var db = new ManagementToolEntities()) { var resp = new ProjectRepository(db); Project project = resp.GetFirstOrDefault(p => p.ProjectID == id); model = transformer.Transform(project); } return(model); }
public RiskVM GetRisk(int riskId) { var model = new RiskVM(); var transformer = new RiskTransformer(); using (var db = new ManagementToolEntities()) { var resp = new RiskRepository(db); var risk = resp.GetFirstOrDefault(r => r.RiskId == riskId); model = transformer.Transform(risk); } return(model); }
public List <CSUser> GetUsersByCompanyId(int companyId) { List <CSUser> users = null; using (var db = new ManagementToolEntities()) { var resp = new UsersRepository(db); var dbUsers = resp.GetAllUsersInCompany(companyId); if (dbUsers != null && dbUsers.Count() > 0) { UserTransformer transformer = new UserTransformer(); users = transformer.Transform(dbUsers); } } return(users); }
public bool UpdateRisk(RiskVM model) { bool success = false; using (var db = new ManagementToolEntities()) { var resp = new RiskRepository(db); var risk = resp.GetFirstOrDefault(r => r.RiskId == model.Id); risk.Status = model.Status.ToString(); risk.Description = model.Description; risk.Title = model.Title; resp.Update(risk); success = db.SaveChanges() > 0; } return(success); }
public bool UpdateProject(ProjectVM model) { bool success = false; using (var db = new ManagementToolEntities()) { var resp = new ProjectRepository(db); Project dbProject = resp.GetFirstOrDefault(p => p.ProjectID == model.Id); dbProject.Description = model.Description; dbProject.DueDate = DateTime.Parse(model.DueDate); dbProject.ProjectManager = model.Manager; dbProject.Status = model.Status.ToString(); dbProject.Title = model.Title; resp.Update(dbProject); success = db.SaveChanges() > 0; } return(success); }
public bool Authenticate(LoginVM user) { using (var db = new ManagementToolEntities()) { var resp = new UsersRepository(db); bool isAuthenticated = false; var account = resp.GetFirstOrDefault(u => u.Email.Trim().ToLower() == user.Email.Trim().ToLower()); if (account != null) { if (user.Password == account.Password) { isAuthenticated = true; } } return(isAuthenticated); } }
public bool UpdateRequirement(RequirementVM model) { bool success = false; using (var db = new ManagementToolEntities()) { var resp = new RequirementRepository(db); var requirement = resp.GetFirstOrDefault(r => r.RequirementId == model.Id); requirement.Type = model.Type.ToString(); requirement.Category = model.Category.ToString(); requirement.Description = model.Description; requirement.Title = model.Title; resp.Update(requirement); success = db.SaveChanges() > 0; } return(success); }
public bool CreateRisk(RiskVM model) { bool success = false; using (var db = new ManagementToolEntities()) { var resp = new RiskRepository(db); var risk = new Risk { Title = model.Title, Description = model.Description, ProjectId = model.ProjectId, Status = model.Status.ToString() }; resp.Insert(risk); success = db.SaveChanges() > 0; } return(success); }
public bool CreateProject(ProjectVM model) { using (var db = new ManagementToolEntities()) { var resp = new ProjectRepository(db); var project = new Project { Title = model.Title, Description = model.Description, ProjectManager = model.Manager, Status = model.Status.ToString(), DueDate = DateTime.Parse(model.DueDate), CompanyId = model.CompanyId, TeamMembers = string.Join(";", model.ProjectEmployees) }; resp.Insert(project); var success = db.SaveChanges() > 0; return(success); } }
public bool CreateRequirement(RequirementVM model) { bool success = false; using (var db = new ManagementToolEntities()) { var resp = new RequirementRepository(db); var requirement = new Requirement { Title = model.Title, Description = model.Description, ProjectId = model.ProjectId, Type = model.Type.ToString(), Category = model.Category.ToString() }; resp.Insert(requirement); success = db.SaveChanges() > 0; } return(success); }
public bool UpdateTask(TaskVM model) { bool success = false; using (var db = new ManagementToolEntities()) { var resp = new TaskRepository(db); DBModels.Task dbTask = resp.GetFirstOrDefault(t => t.TaskID == model.Id); dbTask.Category = model.Category; dbTask.Description = model.Description; dbTask.DueDate = DateTime.Parse(model.DueDate); dbTask.ExpendedHours = model.TaskHours; dbTask.Status = model.Status.ToString(); dbTask.Title = model.Title; dbTask.AssignedTo = model.Developer; resp.Update(dbTask); success = db.SaveChanges() > 0; } return(success); }