public void AddRequest(string id, string desc, string storeId)
        {
            MaintenanceModel md = new MaintenanceModel();

            MaintenanceDTO dto = new MaintenanceDTO();

            UserContext cont = (UserContext)Session["UserContext"];

            if (!ValidationUtility.IsNull(cont))
            {

                if (ValidationUtility.IsEqual("AreaManager", cont.Role))
                {

                    int storId = ValidationUtility.ToInteger(storeId);
                    dto.Status = "pending";
                    dto.StoreId = storId;
                    dto.CategoryId = ValidationUtility.ToInteger(id);
                    dto.Description = desc;
                    md.AddMaintenanceRequest(dto);
                }

                if (ValidationUtility.IsEqual("GeneralManager", cont.Role))
                {

                    int storId = ValidationUtility.ToInteger(storeId);
                    dto.Status = "pending";
                    dto.StoreId = storId;
                    dto.CategoryId = ValidationUtility.ToInteger(id);
                    dto.Description = desc;
                    md.AddMaintenanceRequest(dto);
                }
            }
        }
        public JsonResult MaintenanceRequestList()
        {
            MaintenanceModel md = new MaintenanceModel();
              UserContext cont = (UserContext)Session["UserContext"];
              ArrayList GetMaintenanceList = null;

              if (!ValidationUtility.IsNull(cont))
              {
                  if (ValidationUtility.IsEqual("Admin", cont.Role))
                  {
                      GetMaintenanceList = md.GetMaintenanceList(0);
                  }
                  else if (ValidationUtility.IsEqual("Maintenance", cont.Role))
                  {
                      GetMaintenanceList = md.GetMaintenanceList(0);
                  }
                  else if (ValidationUtility.IsEqual("Manager", cont.Role))
                  {
                      GetMaintenanceList = md.GetMaintenanceList(cont.Id);
                  }
              }
              else
              {
                  GetMaintenanceList = new ArrayList();
              }

              return Json(GetMaintenanceList, JsonRequestBehavior.AllowGet);
        }
        public void DeleteRequest(string id)
        {
            MaintenanceModel md = new MaintenanceModel();

            int mId = ValidationUtility.ToInteger(id);

            md.DeleteMaintenanceRequest(mId);
        }
        public JsonResult GetFilterList(string id)
        {
            MaintenanceModel md = new MaintenanceModel();

            ArrayList list = null;

            if (!ValidationUtility.IsNull(id))
            {
                int storeId = ValidationUtility.ToInteger(id);

                list = md.GetFilterStoreList(storeId,0);

            }
            return Json(list, JsonRequestBehavior.AllowGet);
        }
        public JsonResult AssignStore()
        {
            MaintenanceModel md = new MaintenanceModel();
            UserContext cont = (UserContext)Session["UserContext"];

            ArrayList list = null;

            if (!ValidationUtility.IsNull(cont))
            {
              list =  md.GetAreaMngAssignStore(cont.Id);

            }

            return Json(list, JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetFilterList(string id)
        {
            MaintenanceModel md = new MaintenanceModel();

            ArrayList list = null;

            UserContext cont = (UserContext)Session["UserContext"];

            if (!ValidationUtility.IsNull(id) && !ValidationUtility.IsNull(cont))
            {
                int storeId = ValidationUtility.ToInteger(id);

                list = md.GetFilterStoreList(storeId, cont.Id);

            }
            return Json(list, JsonRequestBehavior.AllowGet);
        }
        public void AddRequest(string sId, string id, string desc)
        {
            MaintenanceModel md = new MaintenanceModel();

            MaintenanceDTO dto = new MaintenanceDTO();

            UserContext cont = (UserContext)Session["UserContext"];

            if (!ValidationUtility.IsNull(cont))
            {

                if (ValidationUtility.IsEqual("Manager", cont.Role))
                {
                    int storId = md.GetStoredId(cont.Id);
                    dto.Status = "pending";
                    dto.StoreId = storId;
                    dto.CategoryId = ValidationUtility.ToInteger(id);
                    dto.Description = desc;
                    md.AddMaintenanceRequest(dto);
                }
                else if (ValidationUtility.IsEqual("Admin", cont.Role) || ValidationUtility.IsEqual("Corporate", cont.Role) || ValidationUtility.IsEqual("Maintenance", cont.Role))
                {
                    //dto.Status = "pending";
                    //dto.CategoryId = ValidationUtility.ToInteger(id);
                    //dto.Description = desc;
                    //md.AddUserStore(ValidationUtility.ToInteger(sId), cont.Id);
                    //int storId = md.GetStoredId(cont.Id);
                    //dto.StoreId = storId;
                    //md.AddMaintenanceRequest(dto);

                    dto.Status = "pending";
                    dto.CategoryId = ValidationUtility.ToInteger(id);
                    dto.Description = desc;
                   // md.AddUserStore(ValidationUtility.ToInteger(sId), cont.Id);
                   // int storId = md.GetStoredId(cont.Id);
                    dto.StoreId = ValidationUtility.ToInteger(sId);
                    md.AddMaintenanceRequest(dto);
                }
            }
        }
 public void UpdateRequest(string id, string desc,string itemName)
 {
     MaintenanceModel md = new MaintenanceModel();
      MaintenanceDTO dto = new MaintenanceDTO();
      dto.Id = ValidationUtility.ToInteger(id);
      dto.CategoryId = md.GetCategoryId(itemName);
      dto.Description = desc;
      md.UpdateMaintenanceRequest(dto, false);
 }
 public JsonResult GetList()
 {
     MaintenanceModel md = new MaintenanceModel();
     ArrayList list =   md.GetList();
     return Json(list, JsonRequestBehavior.AllowGet);
 }
 public void UpdateRequest(string id, string desc, string status, string itemName, string resDate)
 {
     MaintenanceModel md = new MaintenanceModel();
     MaintenanceDTO dto = new MaintenanceDTO();
     dto.Id = ValidationUtility.ToInteger(id);
     dto.CategoryId = md.GetCategoryId(itemName);
     dto.Description = desc;
     dto.Status = status;
     dto.DateResolved = ValidationUtility.ToDate(resDate);
     md.UpdateMaintenanceRequest(dto, true);
 }