Beispiel #1
0
 public bool EndTaskById(int taskId)
 {
     bool result = false;
     try
     {
         Task task = _dbContext.Tasks.Where(a => a.Task_Id == taskId).FirstOrDefault();
         task.End_Date = DateTime.Now.Date;
         task.Status = "COMPLETED";
         _dbContext.Entry(task).State = System.Data.Entity.EntityState.Modified;
         _dbContext.SaveChanges();
         result = true;
     }
     catch (Exception ex)
     {
         result = false;
     }
     return result;
 }
        public bool UpdateUser(User user, int userid)
        {
            bool result = false;

            try
            {
                User userFromDB = _dbContext.Users.Where(a => a.User_Id == userid).FirstOrDefault();
                userFromDB.Employee_Id             = user.Employee_Id;
                userFromDB.FirstName               = user.FirstName;
                userFromDB.LastName                = user.LastName;
                userFromDB.Project_Id              = user.Project_Id;
                userFromDB.Task_Id                 = user.Task_Id;
                _dbContext.Entry(userFromDB).State = System.Data.Entity.EntityState.Modified;
                _dbContext.SaveChanges();
                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }
            return(result);
        }
        public bool UpdateProject(Project project, int projectid)
        {
            bool result = false;

            try
            {
                Project projectFromDB = _dbContext.Projects.Where(a => a.Project_ID == projectid).FirstOrDefault();
                projectFromDB.Project1   = project.Project1;
                projectFromDB.Priority   = project.Priority;
                projectFromDB.EndDate    = project.EndDate;
                projectFromDB.StartDate  = project.StartDate;
                projectFromDB.Project_ID = project.Project_ID;
                _dbContext.Entry(projectFromDB).State = System.Data.Entity.EntityState.Modified;
                _dbContext.SaveChanges();
                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }
            return(result);
        }