/// <summary> /// Remove Task from the database /// </summary> /// <param name="TaskId">TaskId</param> /// <returns>Status of the Operation</returns> public string RemoveTask(int TaskId) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; TaskInformation I = PE.TaskInformations.Where(x => x.TaskId == TaskId).FirstOrDefault(); if (I == null) { return("Task with Id " + TaskId + " Not found"); } else { PE.Entry(I).State = System.Data.Entity.EntityState.Deleted; PE.SaveChanges(); return("Success"); } } } catch (Exception ex) { return("Failed : " + ex.Message); } }
/// <summary> /// Getting All the Task Information from the database /// </summary> /// <returns>List of TaskInformation</returns> public IEnumerable <TaskInformation> GetAllTasks() { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; return(PE.TaskInformations.ToList()); } }
/// <summary> /// Getting All the Project Information from the database /// </summary> /// <returns>List of Project</returns> public IEnumerable <Project> GetAllProject() { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; return(PE.Projects.ToList()); } }
/// <summary> /// Getting the specific Task from the database /// </summary> /// <param name="TaskId">TaskId</param> /// <returns>TaskInformation</returns> public TaskInformation GetTask(int TaskId) { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; TaskInformation i = PE.TaskInformations.Where(x => x.TaskId == TaskId).FirstOrDefault(); return(i); } }
/// <summary> /// Check if task exist or not /// </summary> /// <param name="TaskId"></param> /// <returns></returns> public bool IsTaskExist(int TaskId) { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; bool Result = PE.TaskInformations.Count(x => x.TaskId == TaskId) > 0; return(Result); } }
/// <summary> /// Check if Project exist or not /// </summary> /// <param name="ProjectId"></param> /// <returns></returns> public bool IsProjectExist(int ProjectId) { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; bool Result = PE.Projects.Count(x => x.ProjectId == ProjectId) > 0; return(Result); } }
/// <summary> /// Getting the specific Task from the database /// </summary> /// <param name="ParentTaskId">ParentTaskId</param> /// <returns>Parent</returns> public ParentTask GetParentTask(int ParentTaskId) { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; ParentTask i = PE.ParentTasks.Where(x => x.ParentId == ParentTaskId).FirstOrDefault(); return(i); } }
/// <summary> /// Getting the specific Task from the database /// </summary> /// <param name="ProjectId">ProjectId</param> /// <returns>Project</returns> public Project GetProject(int ProjectId) { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; Project i = PE.Projects.Where(x => x.ProjectId == ProjectId).FirstOrDefault(); return(i); } }
/// <summary> /// Getting the specific User from the database /// </summary> /// <param name="UserId">UserId</param> /// <returns>User</returns> public User GetUser(int UserId) { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; User i = PE.Users.Where(x => x.UserId == UserId).FirstOrDefault(); return(i); } }
/// <summary> /// Check if User exist or not /// </summary> /// <param name="UserId"></param> /// <returns></returns> public bool IsUserExist(int UserId) { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; bool Result = PE.Users.Count(x => x.UserId == UserId) > 0; return(Result); } }
/// <summary> /// Add a particular Parent to database /// </summary> /// <param name="i">Parent</param> /// <returns>Status of the Operation</returns> public ParentTask AddParentTask(ParentTask i) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; PE.ParentTasks.Add(i); PE.SaveChanges(); return(i); } } catch (Exception) { throw; } }
/// <summary> /// Add a particular task to database /// </summary> /// <param name="i">TaskInformation</param> /// <returns>Status of the Operation</returns> public TaskInformation AddTask(TaskInformation i) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; PE.TaskInformations.Add(i); PE.SaveChanges(); return(i); } } catch (Exception) { throw; } }
/// <summary> /// Update a particular ParentTask to database. /// </summary> /// <param name="i">ParentTask</param> /// <returns>Status of The ParentTask</returns> public ParentTask UpdateParentTask(ParentTask i) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; ParentTask value = PE.ParentTasks.Where(x => x.ParentId == i.ParentId).FirstOrDefault(); value.ParentTask1 = i.ParentTask1; PE.SaveChanges(); return(i); } } catch (Exception) { throw; } }
/// <summary> /// Add a particular User to database /// </summary> /// <param name="i">User</param> /// <returns>Status of the Operation</returns> public User AddUser(User i) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; PE.Users.Add(i); PE.SaveChanges(); return(i); } } catch (Exception) { throw; } }
/// <summary> /// Add a particular task to database /// </summary> /// <param name="i">TaskInformation</param> /// <returns>Status of the Operation</returns> public string AddTask(TaskInformation i) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; PE.TaskInformations.Add(i); PE.SaveChanges(); return("Success"); } } catch (Exception ex) { return("Failed" + ex.Message); } }
/// <summary> /// Remove Project from the database /// </summary> /// <param name="ProjectId">ProjectId</param> /// <returns>Status of the Operation</returns> public Project RemoveProject(int ProjectId) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; Project I = PE.Projects.Where(x => x.ProjectId == ProjectId).FirstOrDefault(); PE.Entry(I).State = System.Data.Entity.EntityState.Deleted; PE.SaveChanges(); return(I); } } catch (Exception) { throw; } }
/// <summary> /// Remove Task from the database /// </summary> /// <param name="TaskId">TaskId</param> /// <returns>Status of the Operation</returns> public TaskInformation RemoveTask(int TaskId) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; TaskInformation I = PE.TaskInformations.Where(x => x.TaskId == TaskId).FirstOrDefault(); PE.Entry(I).State = System.Data.Entity.EntityState.Deleted; PE.SaveChanges(); return(I); } } catch (Exception) { throw; } }
/// <summary> /// Remove User from the database /// </summary> /// <param name="UserId">UserId</param> /// <returns>Status of the Operation</returns> public User RemoveUser(int UserId) { try { User I = null; using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; I = PE.Users.Where(x => x.UserId == UserId).FirstOrDefault(); PE.Entry(I).State = System.Data.Entity.EntityState.Deleted; PE.SaveChanges(); } return(I); } catch (Exception) { throw; } }
/// <summary> /// Update a particular User to database. /// </summary> /// <param name="i">User</param> /// <returns>Status of The User</returns> public User UpdateUser(User i) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; User value = PE.Users.Where(x => x.UserId == i.UserId).FirstOrDefault(); value.ProjectId = i.ProjectId; value.LastName = i.LastName; value.FirstName = i.FirstName; value.EmployeeId = i.EmployeeId; PE.SaveChanges(); return(i); } } catch (Exception) { throw; } }
/// <summary> /// Update a particular Project to database. /// </summary> /// <param name="i">Project</param> /// <returns>Status of The Project</returns> public Project UpdateProject(Project i) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; Project value = PE.Projects.Where(x => x.ProjectId == i.ProjectId).FirstOrDefault(); value.Priority = i.Priority; value.StartDate = i.StartDate; value.EndDate = i.EndDate; value.ProjectDescription = i.ProjectDescription; value.ManagerUserId = i.ManagerUserId; PE.SaveChanges(); return(value); } } catch (Exception) { throw; } }
/// <summary> /// Add a particular Project to database /// </summary> /// <param name="i">Project</param> /// <returns>Status of the Operation</returns> public Project AddProject(Project i) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; PE.Projects.Add(i); PE.SaveChanges(); return(i); } } catch (DbEntityValidationException ex) { throw; } catch (Exception) { throw; } }
/// <summary> /// Update a particular task to database. /// </summary> /// <param name="i">TaskInformation</param> /// <returns>Status of The Task</returns> public string UpdateTask(TaskInformation i) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; TaskInformation value = PE.TaskInformations.Where(x => x.TaskId == i.TaskId).FirstOrDefault(); value.Priority = i.Priority; value.StartDate = i.StartDate; value.EndDate = i.EndDate; value.ParentID = i.ParentID; value.TaskDescription = i.TaskDescription; value.IsTaskCompleted = i.IsTaskCompleted; PE.SaveChanges(); return("Updated"); } } catch (Exception ex) { return("failed : " + ex.Message); } }