public JsonResult getOrgDetail(int id)
 {
     try
     {
         using (TaskManagementSystemDB db = new TaskManagementSystemDB())
         {
             int value = db.Organisations.Count();
             if (value > 0)
             {
                 var OrgDetails = db.Organisations.Where(a => a.ORG_ID.Equals(id)).FirstOrDefault();
                 return new JsonResult { Data = OrgDetails, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
             }
         }
         return new JsonResult { Data = null, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
     }
     catch (Exception ex)
     {
         return new JsonResult { Data = ex, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
     }
 }
Example #2
0
 public JsonResult RegisterUser(User RegisterData)
 {
     var dat = new List<object>();
     string msg = "";           
     bool RegisterStatus = false;
     try
     {
         using (TaskManagementSystemDB db = new TaskManagementSystemDB())
         {
             if (ModelState.IsValid)
             {
                 var RegisterUser = db.Users.Where(a => a.U_LOGIN_NAME.Equals(RegisterData.U_LOGIN_NAME)).FirstOrDefault();
                 if (RegisterUser == null)
                 {
                     User newUser = new User();
                     newUser.U_EMAIL = RegisterData.U_EMAIL;
                     newUser.U_FIRST_NAME = RegisterData.U_FIRST_NAME;
                     newUser.U_LAST_NAME = RegisterData.U_LAST_NAME;
                     newUser.U_LOGIN_NAME = RegisterData.U_LOGIN_NAME;
                     newUser.U_PASSWORD = RegisterData.U_PASSWORD;
                     newUser.U_POSITION = RegisterData.U_POSITION;
                     newUser.U_REGISTER_DATE = DateTime.Now;
                     db.Users.Add(newUser);
                     db.SaveChanges();
                     RegisterStatus = true;
                     msg = "Success";
                 }
                 else { msg = "Username already exist!"; }
             }
             else { msg = "Failed!"; }
         }
     } catch (Exception ex) {
         msg = ex.Message;
         dat.Add(new { Status = RegisterStatus, Username = "******", Message = msg });
     }
     dat.Add(new { Status = RegisterStatus, Username = RegisterData.U_LOGIN_NAME, Message = msg });
     return new JsonResult { Data = dat };                                                                                       //, JsonRequestBehavior.AllowGet); //  //return new JsonResult { Data = message };
 
 }
 public JsonResult RecentlyUpdatedTasks(int id)
 {
     List<User> task = new List<User>();
     try
     {
         using (TaskManagementSystemDB db = new TaskManagementSystemDB())
         {
            
                 var updatedTasks = (from TaskAssign in db.TaskAssigned
                              join Tasks in db.Tasks
                                on TaskAssign.TASK_ID_ASSIGNED equals Tasks.TASK_ID
                              where TaskAssign.TASK_UP_DATE != null
                              select ( new 
                              {
                                  TASK_USER          =  TaskAssign.TASK_USER_ID,
                                  USER_TASK_STATUS   =  TaskAssign.TASK_STATUS,
                                  USER_UPDATE_DATE   =  TaskAssign.TASK_UP_DATE,
                                  TASK_ASSIGN_DATE   =  TaskAssign.TASK_ASSIGN_DATE,
                                  TASK_ID            =  TaskAssign.TASK_ID_ASSIGNED,
                                  TASK_NAME          =  Tasks.TASK_NAME,
                                  TASK_STATUS        =  Tasks.TASK_STATUS,
                                  PROJECT_ID         =  Tasks.TASK_PROJECT_ID,
                                  TASK_HOUR_CONSUMED = TaskAssign.TASK_HOUR_CONSUMED,
                                  TASK_DESCRIPTION   =  Tasks.TASK_DESCRIPTION,
                                  TASK_END_DATE      =  Tasks.TASK_END_DATE,
                                  TASK_START_DATE    =  Tasks.TASK_START_DATE   
                                  
                              })).OrderByDescending(USER_UPDATE_DATE => USER_UPDATE_DATE).ToList();
                 return new JsonResult { Data = updatedTasks, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
             
            
         }
     }
     catch (Exception ex) { task = null; }
     return new JsonResult { Data = task, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
 }
Example #4
0
 public JsonResult GetUserType(string uname )
 {
     
     List<User> user = new List<User>();
     try
     {
         using (TaskManagementSystemDB db = new TaskManagementSystemDB())
         {
             var LoggedInUser = db.Users.Where(
                a => a.U_LOGIN_NAME.Equals(uname))
                .FirstOrDefault();
             if (LoggedInUser != null)
                 user = db.Users.Where(a => a.U_LOGIN_NAME.Equals(uname)).ToList();
                 return new JsonResult { Data = uname, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
         }
     }
     catch (Exception Ex)
     {
         // return Ex.ToString();
         Response.Write(Ex);
         return new JsonResult { Data = false, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
     }
    
 }
Example #5
0
 public JsonResult IsUserAvailable(User LoginData)
 {
     bool status = false;
     try
     {
         using (TaskManagementSystemDB db = new TaskManagementSystemDB())
         {
             var LoggedInUser = db.Users.Where(
                a => a.U_LOGIN_NAME.Equals(LoginData.U_LOGIN_NAME))
                .FirstOrDefault();
              if (LoggedInUser != null) status = true;
             return new JsonResult { Data = status, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
         }
     } catch (Exception)  {
         return new JsonResult { Data = status, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
     }
 }
Example #6
0
 public JsonResult GetUserDetails(int id)
 {         
    List<User> user = new List<User>();
     try
     {
         using (TaskManagementSystemDB db = new TaskManagementSystemDB())
         {                                      
             var RegisterUser = db.Users.Where(a => a.U_ID.Equals(id)).FirstOrDefault();
             if (RegisterUser != null)
             {
                 user = db.Users.Where(a => a.U_ID.Equals(id)).OrderBy(a => a.U_LOGIN_NAME).ToList();
             } else { user = null;  }
         }
     } catch (Exception ex) { user = null;  }
     return new JsonResult { Data = user, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
 }
        public JsonResult UpcomingTaskDeadlines(int id)
        {
            List<Task> project = new List<Task>();
            try
            {
                using (TaskManagementSystemDB db = new TaskManagementSystemDB())
                {
                    var TaskList = db.TaskAssigned.Where(a => a.TASK_USER_ID.Equals(id)).Count();
                    if (TaskList > 0)
                    {
                        var dprojects = (from TaskAssign in db.TaskAssigned
                                        join Tasks in db.Tasks
                                        on TaskAssign.TASK_ID_ASSIGNED equals Tasks.TASK_ID
                                        where TaskAssign.TASK_USER_ID == id && (DbFunctions.DiffDays(DateTime.Now, Tasks.TASK_END_DATE).Value > 0 && DbFunctions.DiffDays(DateTime.Now, Tasks.TASK_END_DATE).Value <20)
                                        select (new
                                        {
                                            TASK_ASSIGN_DATE    = TaskAssign.TASK_ASSIGN_DATE,
                                            TASK_HOUR_CONSUMED  = TaskAssign.TASK_HOUR_CONSUMED,
                                            TASK_ID_ASSIGNED    = TaskAssign.TASK_ID_ASSIGNED,
                                            TASK_STATUS         =  TaskAssign.TASK_STATUS,
                                            PROJECT_ID          = TaskAssign.PROJECT_ID,
                                            ID                  = TaskAssign.ID,
                                            TASK_NAME           = Tasks.TASK_NAME,
                                            TASK_START_DATE     = Tasks.TASK_START_DATE,
                                            TASK_END_DATE       = Tasks.TASK_END_DATE,
                                            TASK_DESCRIPTION    = Tasks.TASK_DESCRIPTION,
                                            TASK_PRIORITY       = Tasks.TASK_PRIORITY,
                                            U_TASK_CREATE_DATE  = Tasks.U_TASK_CREATE_DATE,
                                            TASK_USER_ID        = Tasks.TASK_USER_ID,
                                            TASK_ESTIMATED_HOUR =  Tasks.TASK_ESTIMATED_HOUR,

                                            Days = DbFunctions.DiffDays(DateTime.Now, Tasks.TASK_END_DATE).Value

                              })).OrderByDescending(TASK_END_DATE => TASK_END_DATE).ToList();
                        return new JsonResult { Data = dprojects, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
                    }
                    else
                    {
                        return new JsonResult { Data = null, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
                    }
                }
            }  catch (Exception ex)
            {
                
                return new JsonResult { Data = null, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
            }

        }
Example #8
0
        public ActionResult GetTaskDetails(int id)
        {

            List<Task> task = new List<Task>();
            try
            {
                using (TaskManagementSystemDB db = new TaskManagementSystemDB())
                {
                    var TaskDetails = db.Tasks.Where(a => a.TASK_ID.Equals(id)).FirstOrDefault();
                    if (TaskDetails != null)
                    {
                        task = db.Tasks.Where(a => a.TASK_ID.Equals(id)).OrderBy(a => a.TASK_ID).ToList();
                    }
                    else { task = null; }
                }
            }
            catch (Exception ex) { task = null; }
            return new JsonResult { Data = task, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }
Example #9
0
 public JsonResult AssignedTaskList(int id)
 {
     List<Task> task = new List<Task>(); 
     try
     {
         using (TaskManagementSystemDB db = new TaskManagementSystemDB())
         {
             var MyAssignedTaskList = db.TaskAssigned.Where(a => a.TASK_USER_ID.Equals(id)).FirstOrDefault();
             if (MyAssignedTaskList != null)
             {
                 var assignedtasks = (from TaskAssigned in db.TaskAssigned
                              join Task in db.Tasks
                              on TaskAssigned.TASK_ID_ASSIGNED equals Task.TASK_ID
                              where TaskAssigned.TASK_USER_ID == id
                              select (  new {
                                  TASK_ID            =  Task.TASK_ID,
                                  TASK_NAME          =  Task.TASK_NAME,
                                  TASK_PROJECT_ID    =  Task.TASK_PROJECT_ID,
                                  TASK_START_DATE    =  Task.TASK_START_DATE,
                                  TASK_END_DATE      =  Task.TASK_END_DATE,
                                  TASK_PRIORITY      = Task.TASK_PRIORITY,
                                  TASK_STATUS        = Task.TASK_STATUS,
                                  TASK_ESTIMATED_HOUR= Task.TASK_ESTIMATED_HOUR,
                                  TASK_USER_ID       = Task.TASK_USER_ID,
                                  TASK_DESCRIPTION   = Task.TASK_DESCRIPTION,
                                  PROJECT_PHASE      = Task.PROJECT_PHASE,
                                  U_TASK_CREATE_DATE = Task.U_TASK_CREATE_DATE,
                                  TASK_ASSIGN_DATE   = TaskAssigned.TASK_ASSIGN_DATE,
                                  TASK_HOUR_CONSUMED = TaskAssigned.TASK_HOUR_CONSUMED,
                                  ID                 = TaskAssigned.ID,
                                  USER_TASK_STATUS   = TaskAssigned.TASK_STATUS
                              })).ToList();
                 return new JsonResult { Data = assignedtasks, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
             }
             else { task = null; }
         }           
     } catch (Exception ex) {
         task = null;               
     }
     return new JsonResult { Data = task, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
 }
Example #10
0
 /*** listing tasks of a project **/
 public JsonResult getTaskofproject(int id)
 {
     List<Task> task = new List<Task>();
     try
     {
         using (TaskManagementSystemDB db = new TaskManagementSystemDB())
         {
             var TaskList = db.Tasks.Where(a => a.TASK_PROJECT_ID.Equals(id)).OrderBy(a =>a.U_TASK_CREATE_DATE).FirstOrDefault();
             if (TaskList != null){
                 task = db.Tasks.Where(a => a.TASK_PROJECT_ID.Equals(id)).OrderBy(a => a.TASK_NAME).ToList();
             } else { task = null; }
         }
     }
     catch (Exception ex) { task = null; }
     return new JsonResult { Data = task, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
 }
Example #11
0
 public JsonResult MyCreatedTasks(int id) //project manager id 
 {
    List<User> task = new List<User>();
    try
     {
         using (TaskManagementSystemDB db = new TaskManagementSystemDB()){
             var createdTasks = db.Projects.Where(a => a.PROJECT_MANAGER.Equals(id)).FirstOrDefault();
             if (createdTasks != null)
             {
                 var tasks = (from Project in db.Projects
                              join Task in db.Tasks
                              on Project.PROJECT_ID equals Task.TASK_PROJECT_ID
                              where Project.PROJECT_MANAGER == id
                              select new{
                                  Project,
                                  Task                                        
                              }).ToList();
                 return new JsonResult { Data = tasks, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
             } else { task = null; }
         }
     } catch (Exception ex) { task = null; }
     return new JsonResult { Data = task, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
 }
Example #12
0
 public ActionResult GetAssignedUsers(int id) //project id 
 {
     List<User> task = new List<User>();
     try
     {
         using (TaskManagementSystemDB db = new TaskManagementSystemDB())
         {
             var TaskDetails = db.Tasks.Where(a => a.TASK_ID.Equals(id)).FirstOrDefault();
             if (TaskDetails != null)
             {
              var users = (from TaskAssign in db.TaskAssigned join User in db.Users
                           on TaskAssign.TASK_USER_ID equals User.U_ID where TaskAssign.TASK_ID_ASSIGNED == id
                                   select new
                                   {
                                       TaskAssign.TASK_USER_ID,
                                       User.U_LOGIN_NAME,
                                       User.U_FIRST_NAME,
                                       User.U_LAST_NAME,
                                   }).ToList();
                 return new JsonResult { Data = users, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
             }else { task = null; }
         }
     }
     catch (Exception ex) { task = null; }
     return new JsonResult { Data = task, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
 }