Ejemplo n.º 1
0
        public ActionResult Delete(string LeaveId = "", string EmployeeInfoId = "")
        {
            try
            {
                int _leaveId;
                int _employeeInfoId;
                LeaveRequestInfo _leave = null;

                if (!int.TryParse(LeaveId, out _leaveId) || !int.TryParse(EmployeeInfoId, out _employeeInfoId))
                {
                    return(RedirectToAction("Manage", "Leave"));
                }

                using (LeaveRequestRepository Repo = new LeaveRequestRepository())
                {
                    _leave = Repo.GetLeaveRequestById(_leaveId);

                    if (_leave == null)
                    {
                        return(RedirectToAction("Manage", "Leave"));
                    }

                    Repo.DeleteLeaveRequest(_leaveId);
                }

                TempData["Msg"] = AlertMessageProvider.SuccessMessage("Leave(s) deleted successfully.");

                return(RedirectToAction("Manage", "Leave", new { id = EmployeeInfoId }));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Leave", "Delete")));
            }
        }
Ejemplo n.º 2
0
        // GET: Admin/Leave/RequestDetails
        public ActionResult RequestDetails(string id = "")
        {
            try
            {
                int temp;

                if (!int.TryParse(id, out temp))
                {
                    return(RedirectToAction("Requests", "Leave"));
                }

                LeaveRequestInfo leaveRequest = null;

                using (LeaveRequestRepository Repo = new LeaveRequestRepository())
                {
                    leaveRequest = Repo.GetLeaveRequestById(int.Parse(id));
                }

                if (leaveRequest == null)
                {
                    return(RedirectToAction("Requests", "Leave"));
                }

                return(View(leaveRequest));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Leave", "RequestDetails")));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            LeaveRequestInfo              reqInfo   = db.LeaveRequestInfo.Find(id);
            LeaveRequestDescription       reqDes    = getLatestDescription(reqInfo, db);
            EmployeeLeaveRequestViewModel viewModel = mapLeaveRequestToViewModel(reqInfo, reqDes);

            SelectList deliveryManagers   = getEmployeeByRoleName("Delivery Manager");
            SelectList departmentManagers = getEmployeeByRoleName("Department Manager");

            ViewBag.departmentManagerID = departmentManagers;
            ViewBag.deliveryManagerID   = deliveryManagers;

            ViewBag.employeeID    = new SelectList(db.Employees, "employeeID", "employeeName");
            ViewBag.leaveReasonID = new SelectList(db.LeaveReasons, "leaveReasonID", "leaveReasonName");

            if (reqInfo == null)
            {
                return(HttpNotFound());
            }
            return(View(viewModel));
        }
Ejemplo n.º 4
0
        private List <DeliveryManagerLeaveRequestViewModel> mapLeaveRequestsToDelManViewModel(Dictionary <LeaveRequestInfo, LeaveRequestDescription> leaveRequests)
        {
            List <DeliveryManagerLeaveRequestViewModel> viewModel = new List <DeliveryManagerLeaveRequestViewModel>();

            foreach (KeyValuePair <LeaveRequestInfo, LeaveRequestDescription> pair in leaveRequests)
            {
                LeaveRequestInfo        lri = pair.Key;
                LeaveRequestDescription lrd = pair.Value;
                if (lrd.DeliveryManagerStatus.RequestStatusName.Equals("Pending"))
                {
                    viewModel.Add(new DeliveryManagerLeaveRequestViewModel
                    {
                        AllDayEvent            = lrd.AllDayEvent,
                        DeliveryManager        = lrd.DeliveryManager,
                        DeliveryManagerComment = lrd.DeliveryManagerComment,
                        DeliveryManagerStatus  = lrd.DeliveryManagerStatus,
                        Description            = lrd.Description,
                        Employee           = lri.Employee,
                        EndTime            = lrd.EndTime,
                        LeaveReason        = lrd.LeaveReason,
                        StartTime          = lrd.StartTime,
                        LeaveRequestInfoID = lri.LeaveRequestInfoID
                    });
                }
            }
            return(viewModel);
        }
Ejemplo n.º 5
0
        // GET: Admin/Leave/Update
        public ActionResult Update(string id = "")
        {
            try
            {
                int temp;
                LeaveRequestInfo _leave = null;

                if (!int.TryParse(id, out temp))
                {
                    return(RedirectToAction("Manage", "Leave"));
                }

                using (LeaveRequestRepository Repo = new LeaveRequestRepository())
                {
                    _leave = Repo.GetLeaveRequestById(int.Parse(id));
                }

                if (_leave == null)
                {
                    return(RedirectToAction("Manage", "Leave"));
                }

                _leave.Remark = "";

                return(View(_leave));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Leave", "Update")));
            }
        }
Ejemplo n.º 6
0
        public ActionResult Edit([Bind(Include = "leaveRequestID,employeeName,deliveryManagerName,departmentManagerName,allDayEvent,startTime,endTime,leaveReasonID,Description,deliveryManagerID,departmentManagerID")] EmployeeLeaveRequestViewModel employeeLeaveRequestViewModel)
        {
            if (!serverValidation(employeeLeaveRequestViewModel))
            {
                ViewBag.leaveReasonID = new SelectList(db.LeaveReasons, "leaveReasonID", "leaveReasonName");
                return(View(employeeLeaveRequestViewModel));
            }

            LeaveRequestInfo        leaveRequestInfo           = db.LeaveRequestInfo.Find(employeeLeaveRequestViewModel.LeaveRequestID);
            LeaveRequestDescription leaveRequestDesc           = getLatestDescription(leaveRequestInfo, db);
            LeaveRequestDescription newLeaveRequestDescription = mapViewModelToLeaveRequestDesc(employeeLeaveRequestViewModel, leaveRequestInfo);

            if (ModelState.IsValid)
            {
                db.LeaveRequestDescription.Add(newLeaveRequestDescription);
                db.SaveChanges();


                if (employeeLeaveRequestViewModel.DeliveryManagerName.Equals(leaveRequestDesc.DeliveryManager.EmployeeName))
                {
                    sendMailToDelManRequestUpdated(leaveRequestInfo, newLeaveRequestDescription);
                }
                else
                {
                    sendMailToDeliveryManager(leaveRequestInfo, newLeaveRequestDescription);
                }

                return(RedirectToAction("Index"));
            }
            return(View(employeeLeaveRequestViewModel));
        }
Ejemplo n.º 7
0
 private EmployeeLeaveRequestViewModel mapLeaveRequestToViewModel(LeaveRequestInfo reqInfo, LeaveRequestDescription reqDes)
 {
     return(new EmployeeLeaveRequestViewModel()
     {
         AllDayEvent = reqDes.AllDayEvent,
         DeliveryManager = reqDes.DeliveryManager,
         DeliveryManagerComment = reqDes.DeliveryManagerComment,
         DeliveryManagerID = reqDes.DeliveryManager.EmployeeID,
         DeliveryManagerName = reqDes.DeliveryManager.EmployeeName,
         DeliveryManagerStatus = reqDes.DeliveryManagerStatus,
         DepartmentManager = reqDes.DepartmentManager,
         EmployeeName = reqInfo.Employee.EmployeeName,
         Employee = reqInfo.Employee,
         EmployeeID = reqInfo.Employee.EmployeeID,
         DepartmentManagerComment = reqDes.DepartmentManagerComment,
         DepartmentManagerID = reqDes.DepartmentManager.EmployeeID,
         DepartmentManagerName = reqDes.DepartmentManager.EmployeeName,
         DepartmentManagerStatus = reqDes.DepartmentManagerStatus,
         Description = reqDes.Description,
         EndTime = reqDes.EndTime,
         LeaveReason = reqDes.LeaveReason,
         LeaveReasonID = reqDes.LeaveReason.LeaveReasonID,
         LeaveRequestID = reqDes.LeaveRequestInfo.LeaveRequestInfoID,
         StartTime = reqDes.StartTime
     });
 }
Ejemplo n.º 8
0
        public ActionResult ProcessRequest(int id)
        {
            LeaveRequestInfo        reqInfo = db.LeaveRequestInfo.Find(id);
            LeaveRequestDescription reqDes  = EmployeeLeaveRequestViewModelsController.getLatestDescription(reqInfo, db);
            DepartmentManagerLeaveRequestViewModel viewModel = new DepartmentManagerLeaveRequestViewModel()
            {
                AllDayEvent             = reqDes.AllDayEvent,
                DepartmentManager       = reqDes.DepartmentManager,
                DepartmentManagerStatus = reqDes.DepartmentManagerStatus,
                Employee    = reqInfo.Employee,
                EndTime     = reqDes.EndTime,
                Description = reqDes.Description,
                LeaveReason = reqDes.LeaveReason,
                StartTime   = reqDes.StartTime,
                DepartmentManagerComment = reqDes.DepartmentManagerComment,
                LeaveRequestID           = reqInfo.LeaveRequestInfoID
            };

            ViewBag.departmentManagerStatusID = new SelectList(db.RequestStatus, "requestStatusID", "requestStatusName", GetRequestStatusByName(reqDes.DepartmentManagerStatus.RequestStatusName).RequestStatusID);
            ViewData["employeeName"]          = reqInfo.Employee.EmployeeName;
            ViewData["startTime"]             = reqDes.StartTime;
            ViewData["endTime"]     = reqDes.EndTime;
            ViewData["allDayEvent"] = reqDes.AllDayEvent;


            return(View("DepartmentManagerProcessRequest", viewModel));
        }
Ejemplo n.º 9
0
        public void SaveLeaveRequest(LeaveRequestInfo leaveRequestInfo)
        {
            Data.LeaveRequest leaveRequest = ConvertToDb(leaveRequestInfo);

            _context.LeaveRequests.Add(leaveRequest);
            _context.SaveChanges();
        }
Ejemplo n.º 10
0
        private List <DepartmentManagerLeaveRequestViewModel> mapLRToDepManViewModel(Dictionary <LeaveRequestInfo, LeaveRequestDescription> leaveRequests)
        {
            List <DepartmentManagerLeaveRequestViewModel> viewModelList = new List <DepartmentManagerLeaveRequestViewModel>();

            foreach (KeyValuePair <LeaveRequestInfo, LeaveRequestDescription> pair in leaveRequests)
            {
                LeaveRequestInfo        lri = pair.Key;
                LeaveRequestDescription lrd = pair.Value;

                DepartmentManagerLeaveRequestViewModel viewModel = new DepartmentManagerLeaveRequestViewModel()
                {
                    AllDayEvent             = lrd.AllDayEvent,
                    DepartmentManager       = lrd.DepartmentManager,
                    DepartmentManagerStatus = lrd.DepartmentManagerStatus,
                    Employee    = lri.Employee,
                    EndTime     = lrd.EndTime,
                    Description = lrd.Description,
                    LeaveReason = lrd.LeaveReason,
                    StartTime   = lrd.StartTime,
                    DepartmentManagerComment = lrd.DepartmentManagerComment,
                    LeaveRequestID           = lri.LeaveRequestInfoID
                };

                viewModelList.Add(viewModel);
            }

            return(viewModelList);
        }
Ejemplo n.º 11
0
        public ActionResult ProcessRequest(int id, FormCollection collection)
        {
            try
            {
                LeaveRequestInfo        lri = db.LeaveRequestInfo.Find(id);
                LeaveRequestDescription lrd = getLatestDescription(lri);

                string description = Convert.ToString(collection["deliveryManagerComment"]);
                string status      = Convert.ToString(collection["deliveryManagerStatusID"]);
                lrd.DeliveryManagerComment = description;

                lrd.DeliveryManagerStatus = db.RequestStatus.Find(Convert.ToInt32(status));
                db.SaveChanges();

                int employeeID = db.LeaveRequestInfo.Find(id).Employee.EmployeeID;
                if (!lrd.DeliveryManagerStatus.RequestStatusName.Equals("Pending"))
                {
                    sendMailToEmployee(db.LeaveRequestInfo.Find(id).Employee.EmployeeID);
                }
                if (lrd.DeliveryManagerStatus.RequestStatusName.Equals("Approved"))
                {
                    sendMailToDepartmentManager(lri, lrd);
                }


                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("ProcessRequest"));
            }
        }
Ejemplo n.º 12
0
        // GET: Admin/Leave/Add
        public ActionResult Add(string id = "")
        {
            try
            {
                int          empId;
                var          _leave    = new LeaveRequestInfo();
                EmployeeInfo _employee = null;

                if (!int.TryParse(id, out empId))
                {
                    return(RedirectToAction("Manage", "Leave"));
                }

                using (EmployeeRepository Repo = new EmployeeRepository())
                {
                    _employee = Repo.GetEmployeeInfoById(empId);
                }

                if (_employee == null)
                {
                    return(RedirectToAction("Manage", "Leave"));
                }

                _leave.EmployeeInfoId   = _employee.Id;
                _leave.EmployeeFullName = _employee.FirstName + " " + _employee.LastName;

                return(View(_leave));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Leave", "Add")));
            }
        }
Ejemplo n.º 13
0
        public ActionResult printPDF(int?id)
        {
            LeaveRequestInfo        lri = db.LeaveRequestInfo.Find(id);
            LeaveRequestDescription lrd = getLatestDescription(lri, db);
            string tmp = ReplacePdfForm(lri, lrd);

            return(File(@tmp, "application/pdf", lri.Employee.EmployeeName + " " + DateTime.Now + ".pdf"));
        }
Ejemplo n.º 14
0
        private void sendMailToDelManRequestUpdated(LeaveRequestInfo info, LeaveRequestDescription desc)
        {
            Employee employee = db.Employees.Single(e => e.EmployeeID == desc.DeliveryManager.EmployeeID);
            string   email    = employee.EmployeeEmail;
            string   subject  = "Request Updated";
            string   HTMLBody = getHTMLEmailForRequestUpdate(info.Employee.EmployeeName, info.LeaveRequestInfoID);

            sendMailUsingDBSettings(db, employee.EmployeeEmail, subject, HTMLBody);
        }
Ejemplo n.º 15
0
        private void sendMailToDepartmentManager(LeaveRequestInfo info, LeaveRequestDescription desc)
        {
            Employee employee           = db.Employees.Single(e => e.EmployeeID == desc.DepartmentManager.EmployeeID);
            string   email              = employee.EmployeeEmail;
            string   subject            = "New Leave Request";
            string   depManagerHTMLBody = getHTMLEmailForDepManager(info, desc);

            EmployeeLeaveRequestViewModelsController.sendMailUsingDBSettings(db, email, subject, depManagerHTMLBody);
        }
Ejemplo n.º 16
0
        private LeaveRequestDescription getLatestDescription(LeaveRequestInfo lri)
        {
            var q = from l in db.LeaveRequestDescription
                    where l.LeaveRequestInfo.LeaveRequestInfoID == lri.LeaveRequestInfoID
                    select l;

            var latest = q.OrderByDescending(i => i.CreateDate).First();

            return(latest);
        }
Ejemplo n.º 17
0
        public static LeaveRequestDescription getLatestDescription(LeaveRequestInfo lri, LeaveManagerContext db)
        {
            var q = from l in db.LeaveRequestDescription
                    where l.LeaveRequestInfo.LeaveRequestInfoID == lri.LeaveRequestInfoID
                    select l;

            var latest = q.OrderByDescending(i => i.CreateDate).First();

            return(latest);
        }
Ejemplo n.º 18
0
        public ActionResult Index()
        {
            //int pageSize = 5;
            //int pageIndex = 1;
            //pageIndex = page.HasValue ? Convert.ToInt32(page) : 1;
            //IPagedList<LeaveRequestInfo> MI = null;

            using (var client = new HttpClient())
            {
                // Session["UserID"] = 6;
                iLeaveRequestInfo.iMode = 110;
                // iLeaveRequestInfo.Id = Convert.ToInt32(Session["UserID"]); //need to change with session userid
                iLeaveRequestInfo.From = DateTime.Now;
                iLeaveRequestInfo.To   = DateTime.Now;
                client.BaseAddress     = new Uri(Utility.BaseURL);
                var    response = client.PostAsJsonAsync("GetLeaveRequestDetails", iLeaveRequestInfo).Result;
                Status status   = response.Content.ReadAsAsync <Status>().Result;
                if (status.Errors == null)
                {
                    DataTable dt = (DataTable)JsonConvert.DeserializeObject(status.Data.ToString(), (typeof(DataTable)));
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            //string sVal = string.Empty;
                            //if (Convert.ToString(dt.Rows[i]["Status"]) == "Approved/Rejected")
                            //    sVal=
                            //        else

                            iLeaveRequestInfo = new LeaveRequestInfo
                            {
                                Id             = Convert.ToInt32(dt.Rows[i]["Id"]),
                                Name           = Convert.ToString(dt.Rows[i]["Name"]),
                                UserID         = Convert.ToString(dt.Rows[i]["UserID"]),
                                From           = Convert.ToDateTime(dt.Rows[i]["From"]),
                                To             = Convert.ToDateTime(dt.Rows[i]["To"]),
                                Type           = Convert.ToString(dt.Rows[i]["Type"]),
                                Days           = Convert.ToDecimal(dt.Rows[i]["Days"]),
                                Status         = Convert.ToString(dt.Rows[i]["Status"]),
                                Planned        = Convert.ToBoolean(dt.Rows[i]["Planned"]),
                                ArchivedLeaves = Convert.ToDecimal(dt.Rows[i]["ArchivedLeaves"]),
                                LOP            = Convert.ToDecimal(dt.Rows[i]["LOP"]),
                            };

                            //iLeaveRequestInfo.LRI = listItems;
                            //MI = listItems.ToPagedList(pageIndex, pageSize);
                            listItems.Add(iLeaveRequestInfo);
                        }
                    }
                }
            }
            ViewData["Norecords"] = "No records found";
            return(View(listItems));
        }
Ejemplo n.º 19
0
        public ActionResult Index()
        {
            //int pageSize = 5;
            //int pageIndex = 1;
            //pageIndex = page.HasValue ? Convert.ToInt32(page) : 1;
            //IPagedList<LeaveRequestInfo> LR = null;

            using (var client = new HttpClient())
            {
                //Session["UserID"] = 6;
                if (Convert.ToBoolean(Session["IsAdmin"]) == true)
                {
                    iLeaveRequestInfo.iMode = 110;
                }
                else
                {
                    iLeaveRequestInfo.iMode = 123;
                }
                iLeaveRequestInfo.Id   = Convert.ToInt32(Session["UserID"]);
                iLeaveRequestInfo.From = DateTime.Now;
                iLeaveRequestInfo.To   = DateTime.Now;
                client.BaseAddress     = new Uri(Utility.BaseURL);
                var    response = client.PostAsJsonAsync("GetLeaveRequestDetails", iLeaveRequestInfo).Result;
                Status status   = response.Content.ReadAsAsync <Status>().Result;
                if (status.Errors == null)
                {
                    DataTable dt = (DataTable)JsonConvert.DeserializeObject(status.Data.ToString(), (typeof(DataTable)));
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            iLeaveRequestInfo = new LeaveRequestInfo
                            {
                                Name   = Convert.ToString(dt.Rows[i]["Name"]),
                                UserID = Convert.ToString(dt.Rows[i]["UserID"]),
                                From   = Convert.ToDateTime(dt.Rows[i]["From"]),
                                To     = Convert.ToDateTime(dt.Rows[i]["To"]),
                                Type   = Convert.ToString(dt.Rows[i]["Type"]),
                                Days   = Convert.ToDecimal(dt.Rows[i]["Days"]),
                                Status = Convert.ToString(dt.Rows[i]["Status"]),
                                //Message= Convert.ToString(dt.Rows[i]["Message"]),
                                Planned = Convert.ToBoolean(dt.Rows[i]["Planned"]),
                            };

                            //iLeaveRequestInfo.LRI = listItems;
                            //LR = listItems.ToPagedList(pageIndex, pageSize);
                            listItems.Add(iLeaveRequestInfo);
                        }
                    }
                }
            }
            return(View(listItems));
        }
Ejemplo n.º 20
0
        public ActionResult Create(LeaveRequestInfo iLeaveRequestInfo)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    iLeaveRequestInfo.iMode = 107;
                    System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("en-us");

                    string   from = Convert.ToString(iLeaveRequestInfo.DateRange.Split('-')[0].Trim());
                    DateTime dt   = DateTime.Parse(from, cultureinfo);
                    string   To   = Convert.ToString(iLeaveRequestInfo.DateRange.Split('-')[1].Trim());
                    DateTime dtt  = DateTime.Parse(To, cultureinfo);

                    iLeaveRequestInfo.From   = Convert.ToDateTime(dt);
                    iLeaveRequestInfo.To     = Convert.ToDateTime(dtt);
                    iLeaveRequestInfo.UserID = iLeaveRequestInfo.UserID.Split('^')[0];
                    iLeaveRequestInfo.Name   = Convert.ToString(ViewData["MemberName"]);


                    client.BaseAddress = new Uri(Utility.BaseURL);
                    var    response = client.PostAsJsonAsync("SetLeaveRequestDetails", iLeaveRequestInfo).Result;
                    Status status   = response.Content.ReadAsAsync <Status>().Result;
                    if (status.Errors == null)
                    {
                        //string strVerifiedMailPath = System.Web.HttpContext.Current.Server.MapPath(@"../MailFormats/AccountPassword.htm");
                        //System.IO.StreamReader sr = new System.IO.StreamReader(strVerifiedMailPath);
                        //string strVerifiedMailBody = sr.ReadToEnd();
                        //sr.Close();
                        //string strSubject = "Leave Request!";

                        //string strFrom = System.Configuration.ConfigurationManager.AppSettings["RatingMDAdmin"].ToString().Trim();
                        //string strTo = System.Configuration.ConfigurationManager.AppSettings["AdminEmail"].ToString().Trim();
                        //strVerifiedMailBody = strVerifiedMailBody.Replace("$Message$", iLeaveRequestInfo.Message);
                        //strVerifiedMailBody = strVerifiedMailBody.Replace("$Name$", iMemberInfo.FirstName);
                        //Status.SendActionEMail(strFrom, strTo, strSubject, strVerifiedMailBody, "LRS");
                        //TempData["LeaveScriptFunction"] = string.Format("fn_lr_Success();");

                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(View("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                return(View("Index"));
            }
        }
Ejemplo n.º 21
0
        private LeaveRequestInfo mapViewModelToLeaveRequestInfo(EmployeeLeaveRequestViewModel leaveRequestViewModel)
        {
            var emp = getEmployeeByName(leaveRequestViewModel.EmployeeName);

            LeaveRequestInfo newLeaveRequest = new LeaveRequestInfo()
            {
                LeaveRequestInfoID = leaveRequestViewModel.LeaveRequestID,
                Employee           = emp,
                CreateDate         = DateTime.Now,
                UpdateDate         = DateTime.Now
            };

            return(newLeaveRequest);
        }
Ejemplo n.º 22
0
        public ActionResult ProcessRequest(int id)
        {
            LeaveRequestInfo        reqInfo = db.LeaveRequestInfo.Find(id);
            LeaveRequestDescription reqDes  = getLatestDescription(reqInfo);

            ViewData["EmployeeName"]        = reqInfo.Employee.EmployeeName;
            ViewData["allDay"]              = reqDes.AllDayEvent ? "YES" : "NO";
            ViewData["startDate"]           = reqDes.AllDayEvent ? reqDes.StartTime.ToShortDateString() : reqDes.StartTime.ToString();
            ViewData["endDate"]             = reqDes.AllDayEvent ? reqDes.EndTime.ToShortDateString() : reqDes.EndTime.ToString();
            ViewData["leaveReason"]         = reqDes.LeaveReason.LeaveReasonName;
            ViewData["description"]         = reqDes.Description;
            ViewBag.deliveryManagerStatusID = new SelectList(db.RequestStatus, "requestStatusID", "requestStatusName", GetRequestStatusByName(reqDes.DeliveryManagerStatus.RequestStatusName).RequestStatusID);

            return(View());
        }
Ejemplo n.º 23
0
        public ActionResult Index()
        {
            List <String> roles = (List <String>)Session["roles"];
            List <EmployeeLeaveRequestViewModel> requestViewModelList            = new List <EmployeeLeaveRequestViewModel>();
            Dictionary <LeaveRequestInfo, LeaveRequestDescription> leaveRequests = new Dictionary <LeaveRequestInfo, LeaveRequestDescription>();

            if (roles == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            foreach (string role in roles)
            {
                if (role.Equals("Super User"))
                {
                    leaveRequests = getAllLeaveRequests(db);
                }
            }
            if (leaveRequests.Count == 0)
            {
                leaveRequests = getLRForCurrentUser();
            }
            foreach (KeyValuePair <LeaveRequestInfo, LeaveRequestDescription> pair in leaveRequests)
            {
                LeaveRequestInfo        reqInfo = pair.Key;
                LeaveRequestDescription reqDesc = pair.Value;

                EmployeeLeaveRequestViewModel viewModel = new EmployeeLeaveRequestViewModel()
                {
                    AllDayEvent             = reqDesc.AllDayEvent,
                    DeliveryManager         = reqDesc.DeliveryManager,
                    DeliveryManagerStatus   = reqDesc.DeliveryManagerStatus,
                    DepartmentManager       = reqDesc.DepartmentManager,
                    DepartmentManagerStatus = reqDesc.DepartmentManagerStatus,
                    Description             = reqDesc.Description,
                    Employee                 = reqInfo.Employee,
                    EndTime                  = reqDesc.EndTime,
                    LeaveReason              = reqDesc.LeaveReason,
                    LeaveRequestID           = reqInfo.LeaveRequestInfoID,
                    StartTime                = reqDesc.StartTime,
                    DepartmentManagerComment = reqDesc.DepartmentManagerComment,
                    DeliveryManagerComment   = reqDesc.DeliveryManagerComment
                };

                requestViewModelList.Add(viewModel);
            }
            return(View(requestViewModelList.AsQueryable()));
        }
Ejemplo n.º 24
0
        public void ApproveLeaveRequest(LeaveRequestInfo leaveRequestInfo)
        {
            Data.LeaveRequest leaveRequest = _context.LeaveRequests.Find(leaveRequestInfo.Id);

            if (leaveRequest != null)
            {
                leaveRequest.Status                    = leaveRequestInfo.Status;
                leaveRequest.RequestProcessDate        = leaveRequestInfo.RequestProcessDate;
                leaveRequest.RequestProcessByAccountId = leaveRequestInfo.RequestProcessByAccountId;

                _context.SaveChanges();
            }
            else
            {
                throw new ArgumentNullException();
            }
        }
Ejemplo n.º 25
0
 public Data.LeaveRequest ConvertToDb(LeaveRequestInfo leaveRequestInfo)
 {
     return(new Data.LeaveRequest
     {
         Id = leaveRequestInfo.Id,
         RequestDate = leaveRequestInfo.RequestDate,
         StartDate = leaveRequestInfo.StartDate,
         EndDate = leaveRequestInfo.EndDate,
         LeaveType = leaveRequestInfo.LeaveType,
         Reason = leaveRequestInfo.Reason,
         Status = leaveRequestInfo.Status,
         Remark = leaveRequestInfo.Remark,
         IsCreatedByAdmin = leaveRequestInfo.IsCreatedByAdmin,
         RequestProcessDate = leaveRequestInfo.RequestProcessDate,
         RequestProcessByAccountId = leaveRequestInfo.RequestProcessByAccountId,
         EmployeeInfoId = leaveRequestInfo.EmployeeInfoId
     });
 }
Ejemplo n.º 26
0
        public ActionResult ProcessRequest([Bind(Include = "leaveRequestID,departmentManagerComment,departmentManagerStatusID")] DepartmentManagerLeaveRequestViewModel departmentManagerLeaveRequestViewModel)
        {
            if (ModelState.IsValid)
            {
                LeaveRequestInfo        requestToUpdate = db.LeaveRequestInfo.Find(departmentManagerLeaveRequestViewModel.LeaveRequestID);
                LeaveRequestDescription descToUpdate    = EmployeeLeaveRequestViewModelsController.getLatestDescription(requestToUpdate, db);
                descToUpdate.DepartmentManagerComment = departmentManagerLeaveRequestViewModel.DepartmentManagerComment;
                descToUpdate.DepartmentManagerStatus  = db.RequestStatus.Find(departmentManagerLeaveRequestViewModel.DepartmentManagerStatusID);
                db.SaveChanges();

                if (!descToUpdate.DepartmentManagerStatus.RequestStatusName.Equals("Pending"))
                {
                    sendMailToEmployee(requestToUpdate.Employee.EmployeeID);
                }
                return(RedirectToAction("Index"));
            }

            return(View());
        }
Ejemplo n.º 27
0
        private string getHTMLEmailForDepManager(LeaveRequestInfo info, LeaveRequestDescription desc)
        {
            StreamReader reader = new StreamReader(Server.MapPath("~/Content/MailTemplate.html"));
            string       email  = reader.ReadToEnd();

            string notHeader   = "You have new leave request";
            string textHeader  = "";
            string textMessage = "You have recieved new leave request from:  <i style=\"color: green\">" + info.Employee.EmployeeName + "</i> Approved by delivery manager:  <i style=\"color: #FF8000\">" + desc.DeliveryManager.EmployeeName + "</i><br/>";
            string buttonText  = "Go to request";

            string buttonLink = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "DepartmentManagerLeaveRequestViewModels/ProcessRequest/" + info.LeaveRequestInfoID;

            email = email.Replace("[NotificationHeader]", notHeader);
            email = email.Replace("[TextHeader]", textHeader);
            email = email.Replace("[TextMessage]", textMessage);
            email = email.Replace("[ButtonText]", buttonText);
            email = email.Replace("[ButtonLink]", buttonLink);

            return(email);
        }
Ejemplo n.º 28
0
        public ActionResult Update(LeaveRequestInfo leaveRequestInfo)
        {
            try
            {
                leaveRequestInfo.RequestProcessDate        = DateTime.Now;
                leaveRequestInfo.RequestProcessByAccountId = CurrentUser.AccountId;

                using (LeaveRequestRepository Repo = new LeaveRequestRepository())
                {
                    Repo.UpdateLeaveRequest(leaveRequestInfo);
                }

                TempData["Msg"] = AlertMessageProvider.SuccessMessage("Leave(s) updated successfully.");

                return(RedirectToAction("Manage", "Leave", new { id = leaveRequestInfo.EmployeeInfoId }));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Leave", "Update")));
            }
        }
Ejemplo n.º 29
0
 // GET: LeaveRequest
 public ActionResult Index()
 {
     using (var client = new HttpClient())
     {
         //Session["UserID"] = 6;
         iLeaveRequestInfo.iMode = 110;
         // iLeaveRequestInfo.Id = Convert.ToInt32(Session["UserID"]);
         iLeaveRequestInfo.From = DateTime.Now;
         iLeaveRequestInfo.To   = DateTime.Now;
         client.BaseAddress     = new Uri(Utility.BaseURL);
         var    response = client.PostAsJsonAsync("GetLeaveRequestDetails", iLeaveRequestInfo).Result;
         Status status   = response.Content.ReadAsAsync <Status>().Result;
         if (status.Errors == null)
         {
             DataTable dt = (DataTable)JsonConvert.DeserializeObject(status.Data.ToString(), (typeof(DataTable)));
             if (dt.Rows.Count > 0)
             {
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
                     iLeaveRequestInfo = new LeaveRequestInfo
                     {
                         Name    = Convert.ToString(dt.Rows[i]["Name"]),
                         UserID  = Convert.ToString(dt.Rows[i]["UserID"]),
                         From    = Convert.ToDateTime(dt.Rows[i]["From"]),
                         To      = Convert.ToDateTime(dt.Rows[i]["To"]),
                         Type    = Convert.ToString(dt.Rows[i]["Type"]),
                         Days    = Convert.ToDecimal(dt.Rows[i]["Days"]),
                         Status  = Convert.ToString(dt.Rows[i]["Status"]),
                         Planned = Convert.ToBoolean(dt.Rows[i]["Planned"]),
                     };
                     listItems.Add(iLeaveRequestInfo);
                 }
             }
         }
     }
     ViewData["Norecords"] = "No records found";
     return(View(listItems));
 }
Ejemplo n.º 30
0
        public ActionResult Create(LeaveRequestInfo iLeaveRequestInfo)
        {
            //if (string.IsNullOrWhiteSpace(iLeaveRequestInfo.Name))
            //    ModelState.AddModelError("Name", "select name");
            //if (!ModelState.IsValid)
            //{
            //    return RedirectToAction("Create");
            //}

            try
            {
                using (var client = new HttpClient())
                {
                    //Session["UserID"] = 6;
                    iLeaveRequestInfo.iMode = 107;
                    //int recordid = Convert.ToInt32(Session["recordid"]) + 1;
                    //iLeaveRequestInfo.RecordID = recordid;
                    //iLeaveRequestInfo.UserID = Convert.ToString(Session["UserID"]);
                    // int Days = Convert.ToInt32((Convert.ToDateTime(iLeaveRequestInfo.To) - Convert.ToDateTime(iLeaveRequestInfo.From)).TotalDays) + 1;
                    //iLeaveRequestInfo.Days = Days;
                    client.BaseAddress = new Uri(Utility.BaseURL);
                    var    response = client.PostAsJsonAsync("SetLeaveRequestDetails", iLeaveRequestInfo).Result;
                    Status status   = response.Content.ReadAsAsync <Status>().Result;
                    if (status.Errors == null)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(View("Index"));
                    }
                }
            }
            catch
            {
                return(View("Index"));
            }
        }