Beispiel #1
0
        public ActionResult DeleteEmployeeDesk(long id)
        {
            var gVal = new GenericValidator();

            try
            {
                if (id < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Invalid selection";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                var delStatus = new EmployeeDeskServices().DeleteEmployeeDesk(id);
                if (delStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "EmployeeDesk could not be deleted. Please try again later.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = 5;
                gVal.Error = "EmployeeDesk Information was successfully deleted";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
0
        public ActionResult EditEmployeeDesk(EmployeeDeskObject employeeDesk)
        {
            var gVal = new GenericValidator();

            try
            {
                if (string.IsNullOrEmpty(employeeDesk.GroupName.Trim()))
                {
                    gVal.Code  = -1;
                    gVal.Error = "Please provide EmployeeDesk.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (Session["_EmployeeDesk"] == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var oldEmployeeDesk = Session["_EmployeeDesk"] as EmployeeDeskObject;

                if (oldEmployeeDesk == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }


                oldEmployeeDesk.EmployeeName = employeeDesk.EmployeeName.Trim();

                var docStatus = new EmployeeDeskServices().UpdateEmployeeDesk(oldEmployeeDesk);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "EmployeeDesk information could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = oldEmployeeDesk.Id;
                gVal.Error = "EmployeeDesk information was successfully updated";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "EmployeeDesk information could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #3
0
        public ActionResult GetEmployeeDeskObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <EmployeeDeskObject> filteredParentMenuObjects;
                var countG = 0;

                var pagedParentMenuObjects = GetEmployeeDesks(param.iDisplayLength, param.iDisplayStart, out countG);

                if (!string.IsNullOrEmpty(param.sSearch))
                {
                    filteredParentMenuObjects = new EmployeeDeskServices().Search(param.sSearch);
                }
                else
                {
                    filteredParentMenuObjects = pagedParentMenuObjects;
                }

                if (!filteredParentMenuObjects.Any())
                {
                    return(Json(new List <EmployeeDeskObject>(), JsonRequestBehavior.AllowGet));
                }

                var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
                Func <EmployeeDeskObject, string> orderingFunction = (c => sortColumnIndex == 1 ? c.EmployeeName : c.GroupName);

                var sortDirection = Request["sSortDir_0"]; // asc or desc
                filteredParentMenuObjects = sortDirection == "desc" ? filteredParentMenuObjects.OrderBy(orderingFunction) : filteredParentMenuObjects.OrderByDescending(orderingFunction);

                var displayedPersonnels = filteredParentMenuObjects;

                var result = from c in displayedPersonnels
                             select new[] { Convert.ToString(c.Id), c.EmployeeName, c.GroupName, c.ActivityTypeName, c.ZoneName, c.JobCountStr };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = countG,
                    iTotalDisplayRecords = countG,
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <EmployeeDeskObject>(), JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #4
0
        public ActionResult GetEmployeeDesk(long id)
        {
            try
            {
                var employeeDesk = new EmployeeDeskServices().GetEmployeeDesk(id);
                if (employeeDesk == null || employeeDesk.Id < 1)
                {
                    return(Json(new EmployeeDeskObject(), JsonRequestBehavior.AllowGet));
                }

                Session["_EmployeeDesk"] = employeeDesk;

                return(Json(employeeDesk, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new EmployeeDeskObject(), JsonRequestBehavior.AllowGet));
            }
        }