コード例 #1
0
 public HttpResponseMessage employeeConfirm(ManageTaskRequest request)
 {
     HttpResponseMessage response = new HttpResponseMessage();
     try
     {
         ManageTaskAdapter adp = new ManageTaskAdapter();
         ManageTaskResponse result = adp.EmployeeConfirm(request);
         response = Request.CreateResponse(HttpStatusCode.OK, result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return response;
 }
コード例 #2
0
        public ManageTaskResponse Approval(ManageTaskRequest request)
        {
            ManageTaskResponse response = new ManageTaskResponse();

            using (var context = new Company_dbEntities())
            {
                var approve = (from a in context.Task_table where a.EmployeeID == request.UserName && a.Description == request.Description && a.EmployeeConfirm == "Completed" select a).FirstOrDefault<Task_table>();

                if (request.Accept == true)
                {
                    if (approve != null)
                    {

                        approve.ManagerConfirm = request.ManagerConfirm;

                        context.SaveChanges();
                        response.ConfirmManager = true;
                    }
                    else
                    {
                        response.ConfirmManager = false;
                    }
                }

                else
                {
                    if (approve != null)
                    {

                        approve.ManagerConfirm = request.ManagerConfirm;
                        approve.EmployeeConfirm = "Pending";
                        context.SaveChanges();
                        response.ConfirmManager = true;
                    }
                    else
                    {
                        response.ConfirmManager = false;
                    }
                }
            }
            return response;
        }
コード例 #3
0
        public ManageTaskResponse DeleteTask(ManageTaskRequest request)
        {
            ManageTaskResponse response = new ManageTaskResponse();

            using (var context = new Company_dbEntities())
            {
                var delete = (from a in context.Task_table where a.EmployeeID == request.UserName && a.Description == request.Description select a).FirstOrDefault<Task_table>();

                if (delete != null)
                {

                     context.Task_table.Remove(delete);
                     context.SaveChanges();
                     response.TaskDeleted = true;

                }
                else
                {
                    response.TaskDeleted = false;
                }
            }
            return response;
        }
コード例 #4
0
        public ManageTaskResponse AddTask(ManageTaskRequest request)
        {
            ManageTaskResponse response = new ManageTaskResponse();
            //int? empId = AdapterHelper.GetEmployeeId(request.AssignedBy, request.Email);
            //if (!empId.HasValue)
            //    throw new Exception("Employee does not exist!");

            using (var context = new Company_dbEntities())
            {
                Task_table task = new Task_table();
                task.EmployeeID = request.UserName;
                task.EmployeeName = request.EmployeeName;
                task.Description = request.Description;
                task.AssignedBy = request.AssignedBy;
                task.EmployeeConfirm = request.EmployeeConfirm;

                context.Task_table.Add(task);
                context.SaveChanges();

                response.TaskAdded = true;
            }

            return response;
        }
コード例 #5
0
        public ManageTaskResponse TaskAssign(ManageTaskRequest request)
        {
            ManageTaskResponse response = new ManageTaskResponse();

            //int? empId = AdapterHelper.GetEmployeeId(request.EmployeeName, request.Email);
            //if (!empId.HasValue)
            //    throw new Exception("Employee does not exist!");
            List<Task_table> task = new List<Task_table>();
            List<task> list = new List<task>();
            using (var context = new Company_dbEntities())
            {
                task = (from a in context.Task_table where a.AssignedBy == request.UserName select a).ToList();

                if(task != null)
                {
                    foreach(var entry in task)
                    {
                        task t = new task();

                        t.EmployeeID = entry.EmployeeID;
                        t.EmployeeName = entry.EmployeeName;
                        t.Description = entry.Description;
                        t.EmployeeConfirm = entry.EmployeeConfirm;
                        t.ManagerConfirm = entry.ManagerConfirm;

                        list.Add(t);
                    }
                    response.TaskAssign = JsonConvert.SerializeObject(list);
                }
                else
                {
                    response.TaskAssign = null;
                }

            }
            return response;
        }
コード例 #6
0
        public ManageTaskResponse EmployeeConfirm(ManageTaskRequest request)
        {
            ManageTaskResponse response = new ManageTaskResponse();

            using(var context = new Company_dbEntities())
            {
              var  confirm = (from a in context.Task_table where a.EmployeeID == request.UserName && a.Description == request.Description && a.AssignedBy == request.AssignedBy select a).FirstOrDefault<Task_table>();

                if(confirm != null)
                {

                    if(confirm.EmployeeConfirm == "Completed" && confirm.ManagerConfirm == "Approved")
                    {
                        context.SaveChanges();
                        response.ConfirmEmployee = true;
                    }
                    else
                    {
                    confirm.EmployeeConfirm = request.EmployeeConfirm;
                    confirm.ManagerConfirm = null;
                    context.SaveChanges();
                    response.ConfirmEmployee = true;
                    }
                }
                else
                {
                    response.ConfirmEmployee = false;
                }

            }
            return response;
        }