Пример #1
0
        public void UpdateTask(Task task)
        {
            db.Entry(task).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
            }

            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
Пример #2
0
 /// <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);
     }
 }
Пример #3
0
 /// <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;
     }
 }
Пример #4
0
        /// <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;
            }
        }
Пример #5
0
 /// <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;
     }
 }
Пример #6
0
        /// <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;
            }
        }
Пример #7
0
        /// <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);
            }
        }
Пример #8
0
        /// <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;
            }
        }
Пример #9
0
        /// <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;
            }
        }
Пример #10
0
        /// <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;
            }
        }
Пример #11
0
 /// <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;
     }
 }
Пример #12
0
 /// <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;
     }
 }
Пример #13
0
        /// <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;
            }
        }
Пример #14
0
 /// <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);
     }
 }