public JsonResult Logout()
        {
            string error = "";
            string msg = "";

            try
            {
                Session["user"] = null;
                Session["UserContext"] = null;
                Session["ConnectionString"] = null;

                Session.Clear();
                Session.Abandon();
                Session.RemoveAll();
                error = "Success";
                msg = "Session Expired Successfully";

            }
            catch (Exception ex)
            {
                error = "Error";
                msg = "Session  ";
                // log.Error("Exception in UpdateDepositStatus ", ex);
            }

            ResponseDTO resDTO = new ResponseDTO { Error = error, Message = msg };
            return Json(resDTO, JsonRequestBehavior.AllowGet);
        }
        // Check Session
        public JsonResult CheckSession()
        {
            string error = "";
            string msg = "";

            try
            {
                if (!ValidationUtility.IsNull(Session["UserContext"]))
                {
                    error = "Success";
                    msg = "Session is not Expired ";
                }
                else
                {
                    error = "Error";
                    msg = "Session  ";
                }

            }
            catch (Exception ex)
            {
                error = "Error";
                msg = "Session  ";
                // log.Error("Exception in UpdateDepositStatus ", ex);
            }

            ResponseDTO resDTO = new ResponseDTO { Error = error, Message = msg };
            return Json(resDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult AddCurrentYearGoals(string foodCost, string laborCost, string salesIncrease, string auv,
            string unitFootlongSales, string fsPercent, string drinkCount, string checkItem, string checkIndex,
            string customerCount, string customerCountIndex, string unit, string ui, string productivity, string factor)
        {
            GoalsModel goalsModel = new GoalsModel();

            double fCost = ValidationUtility.ToDouble(foodCost);
            double lCost = ValidationUtility.ToDouble(laborCost);

            double foodLaborCost = fCost + lCost;
               // ArrayList storeList = ValidationUtility.GetStoreList(false);

            ArrayList storeList = ValidationUtility.GetActiveStoreList(false);

            ResponseDTO responseDTO = null;

            foreach (StoreDTO StoreDTO in storeList)
            {
                GoalsDTO goalsDTO = new GoalsDTO();

                goalsDTO.StoreId = StoreDTO.Id;
                goalsDTO.Year = DateTime.Now.Year;
                goalsDTO.FoodCost = fCost;
                goalsDTO.LaborCost = lCost;
                goalsDTO.FoodLaborCost = foodLaborCost;
                goalsDTO.SalesIncrease = ValidationUtility.ToDouble(salesIncrease);
                goalsDTO.Auv = ValidationUtility.ToDouble(auv);
                goalsDTO.UnitFootlongSales = ValidationUtility.ToDouble(unitFootlongSales);
                goalsDTO.FsPercent = ValidationUtility.ToDouble(fsPercent);
                goalsDTO.DrinkCount = ValidationUtility.ToDouble(drinkCount);
                goalsDTO.CheckItem = ValidationUtility.ToDouble(checkItem);
                goalsDTO.CheckIndex = ValidationUtility.ToDouble(checkIndex);
                goalsDTO.CustomerCount = ValidationUtility.ToDouble(customerCount);
                goalsDTO.CustomerCountIndex = ValidationUtility.ToDouble(customerCountIndex);
                goalsDTO.Unit = ValidationUtility.ToDouble(unit);
                goalsDTO.Ui = ValidationUtility.ToDouble(ui);
                goalsDTO.Productivity = ValidationUtility.ToDouble(productivity);
                goalsDTO.Factor = ValidationUtility.ToDouble(factor);

                if (!goalsModel.IsCurrentYearGoalsExist(StoreDTO.Id, DateTime.Now.Year))
                {
                    // goalsModel.AddPreviousYearAchiveGoals(goalsDTO);
                    goalsModel.AddGoals(goalsDTO);
                    goalsModel.AddCurrentYearYTDGoals(goalsDTO);
                    goalsModel.AddPreviousYearAchiveGoals(goalsDTO);

                    responseDTO = new ResponseDTO { Error = "Success", Message = "Add Successfully" };

                }
                else
                {
                    responseDTO = new ResponseDTO { Error = "Error", Message = "Records Allready Exists Now you can Update Only" };
                }

            }

            return Json(responseDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult AddFoodItem(string item)
        {
            string error = "";
            string msg = "";

            try
            {
                FoodOrderModel foodOredeModel = new FoodOrderModel();
                foodOredeModel.AddFoodOrderItem(item);
                error = "Success";
                msg = "Food Item is Added Successfully";

            }
            catch (Exception ex)
            {
                error = "Error";
                msg = "Food Item is not Added";
                log.Error(" Exception in AddFoodItem Method ", ex);

            }

            ResponseDTO resDTO = new ResponseDTO { Error = error, Message = msg };
            return Json(resDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult AddFoodOrder(string[] ids, string[] leftValue, string[] overValue)
        {
            UserContext cont = (UserContext)Session["UserContext"];

            FoodOrderModel fom = new FoodOrderModel();

            string error = "";
            string msg = "";

            try
            {

                if (!ValidationUtility.IsNull(ids) && ids.Length > 0 && !ValidationUtility.IsNull(cont))
                {
                    FoodOrderDTO foodOrderDTO = new FoodOrderDTO();

                    foodOrderDTO.StoreId = fom.GetStoredId(cont.Id);

                    foodOrderDTO.FoodOrderDate = DateTime.Now;
                    foodOrderDTO.CreatedDateTime = DateTime.Now;
                    foodOrderDTO.LastUpdateDateTime = DateTime.Now;

                    fom.AddFoodOrder(foodOrderDTO);

                    int foodId = fom.GetFoodOrderId(foodOrderDTO);

                    for (int i = 0; i < ids.Length; i++)
                    {
                        int itemId = ValidationUtility.ToInteger(ids[i]);
                        int left = ValidationUtility.ToInteger(leftValue[i]);
                        int over = ValidationUtility.ToInteger(overValue[i]);

                        OrderDTO dto = new OrderDTO();
                        dto.ItemId = itemId;
                        dto.NumberRemaining = left;
                        dto.NumberOver = over;
                        dto.FoodOrderId = foodId;
                        dto.CreatedDateTime = DateTime.Now;
                        dto.LastUpdateDateTime = DateTime.Now;
                        fom.AddOrder(dto);

                    }

                    error = "Success";
                    msg = "Food Order Added Successfully";
                }
            }
            catch (Exception ex)
            {
                error = "Error";
                msg = "Food Order is not Added Please Try Again";
                log.Error(" Exception in AddFoodItem Method ", ex);
            }

            ResponseDTO resDTO = new ResponseDTO { Error = error, Message = msg };
            return Json(resDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult DeletFoodItem(string foodItemId)
        {
            string error = "";
            string msg = "";

            try
            {
                FoodOrderModel foodOrderModel = new FoodOrderModel();
                int itemId = ValidationUtility.ToInteger(foodItemId);
                foodOrderModel.DeleteFoodItem(itemId);
                error = "Success";
                msg = "Food Item is Deleted Successfully";
            }
            catch (Exception ex)
            {
                error = "Error";
                msg = "Food Item is not Deleted";
                log.Error(" Exception in DeletFoodItem Method ", ex);

            }

            ResponseDTO resDTO = new ResponseDTO { Error = error, Message = msg };
            return Json(resDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult UpdateCurrentYearGoals(string tId, string sId, string foodCost, string laborCost, string salesIncrease, string auv,
            string unitFootlongSales, string fsPercent, string drinkCount, string checkItem, string checkIndex,
            string customerCount, string customerCountIndex, string unit, string ui, string productivity, string factor)
        {
            GoalsModel goalsModel = new GoalsModel();

            double fCost = ValidationUtility.ToDouble(foodCost);
            double lCost = ValidationUtility.ToDouble(laborCost);

            double foodLaborCost = fCost + lCost;
            GoalsDTO goalsDTO = new GoalsDTO();

            goalsDTO.Id = ValidationUtility.ToInteger(tId);
            goalsDTO.StoreId = ValidationUtility.ToInteger(sId);
            goalsDTO.FoodCost = fCost;
            goalsDTO.LaborCost = lCost;
            goalsDTO.FoodLaborCost = foodLaborCost;
            goalsDTO.SalesIncrease = ValidationUtility.ToDouble(salesIncrease);
            goalsDTO.Auv = ValidationUtility.ToDouble(auv);
            goalsDTO.UnitFootlongSales = ValidationUtility.ToDouble(unitFootlongSales);
            goalsDTO.FsPercent = ValidationUtility.ToDouble(fsPercent);
            goalsDTO.DrinkCount = ValidationUtility.ToDouble(drinkCount);
            goalsDTO.CheckItem = ValidationUtility.ToDouble(checkItem);
            goalsDTO.CheckIndex = ValidationUtility.ToDouble(checkIndex);
            goalsDTO.CustomerCount = ValidationUtility.ToDouble(customerCount);
            goalsDTO.CustomerCountIndex = ValidationUtility.ToDouble(customerCountIndex);
            goalsDTO.Unit = ValidationUtility.ToDouble(unit);
            goalsDTO.Ui = ValidationUtility.ToDouble(ui);
            goalsDTO.Productivity = ValidationUtility.ToDouble(productivity);
            goalsDTO.Factor = ValidationUtility.ToDouble(factor);

            goalsModel.UpdateGoals(goalsDTO);

            ResponseDTO responseDTO = new ResponseDTO { Error = "Success", Message = "Add Successfully" };

            return Json(responseDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult DeleteUser(int id)
        {
            LoginUserModel lgModel = new LoginUserModel();

            string error = "";
            string msg = "";

            try
            {
                lgModel.Delete(id);
                error = "Success";
                msg = "User Deleted Successfully";
            }
            catch (Exception ex)
            {

                error = "Error";
                msg = "User is not Deleted";
                log.Error(" Exception in DeleteUser Method ", ex);
            }

            ResponseDTO resDTO = new ResponseDTO { Error = error, Message = msg };
            return Json(resDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult UpdateDepositStatus(string id, string status)
        {
            string error = "";
            string msg = "";

            try
            {
                DepositModel depositModel = new DepositModel();
                int Id = ValidationUtility.ToInteger(id);
                depositModel.UpdaqteDepositModel(Id, status);
                error = "Success";
                msg = "Status Changed Successfully";

            }
            catch (Exception ex)
            {
                error = "Error";
                msg = "Status is not Changed ";
                log.Error("Exception in UpdateDepositStatus ",ex);
            }

            ResponseDTO resDTO = new ResponseDTO { Error = error, Message = msg };
            return Json(resDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult UpdateZeroBasisValues(string tId, string sId, string foodCost, string laborCost, string salesIncrease,
            string customerIndex, string customerComplaint, string catering, string subInspection)
        {
            ManagerBonusModel managerBonusModel = new ManagerBonusModel();

            ManagerBonusDTO managerBonusDTO = new ManagerBonusDTO();

            double fCost = ValidationUtility.ToDouble(foodCost);
            double lCost = ValidationUtility.ToDouble(laborCost);

            double foodLaborCost = fCost + lCost;

            managerBonusDTO.Id = ValidationUtility.ToInteger(tId);
            managerBonusDTO.StoreId = ValidationUtility.ToInteger(sId);
            managerBonusDTO.FoodCost = fCost;
            managerBonusDTO.LaborCost = lCost;
            managerBonusDTO.FoodLaborCost = foodLaborCost;
            managerBonusDTO.SalesIncrease = ValidationUtility.ToDouble(salesIncrease);
            managerBonusDTO.CustomerIndex = ValidationUtility.ToDouble(customerIndex);
            managerBonusDTO.CustomerComplaint = ValidationUtility.ToDouble(customerComplaint);
            managerBonusDTO.Catering = ValidationUtility.ToDouble(catering);
            managerBonusDTO.SubInspection = ValidationUtility.ToDouble(subInspection);

            managerBonusModel.UpdateZeroBasis(managerBonusDTO);

            ResponseDTO responseDTO = new ResponseDTO { Error = "Success", Message = "Update Successfully" };

            return Json(responseDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult UpdateSubInspection(string tId, string sId, string subInspection)
        {
            ManagerBonusModel managerBonusModel = new ManagerBonusModel();

            ManagerBonusDTO managerBonusDTO = new ManagerBonusDTO();
            managerBonusDTO.Id = ValidationUtility.ToInteger(tId);

            managerBonusDTO.StoreId = ValidationUtility.ToInteger(sId);
            managerBonusDTO.SubInspection = ValidationUtility.ToDouble(subInspection);

            managerBonusModel.UpdateSubInspectionValue(managerBonusDTO);

            ResponseDTO responseDTO = new ResponseDTO { Error = "Success", Message = "Sub Inspection Update Successfully" };

            return Json(responseDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult AddZeroBasis(String selectDate, string foodCost, string laborCost, string salesIncrease,
            string customerIndex, string customerComplaint, string catering, string subInspection)
        {
            ManagerBonusModel managerBonusModel = new ManagerBonusModel();

            ArrayList storeList = ValidationUtility.GetStoreList(false);

            double fCost = ValidationUtility.ToDouble(foodCost);
            double lCost = ValidationUtility.ToDouble(laborCost);

            double foodLaborCost = fCost + lCost;

            DateTime formatedDate;
            DateTime givenMontWeekStartDate;
            DateTime montEndDate;

            if (!ValidationUtility.IsNull(selectDate))
            {
                formatedDate = ValidationUtility.ToDate(selectDate);

                givenMontWeekStartDate = ValidationUtility.MonthWeekStartDate(formatedDate);

                montEndDate = ValidationUtility.MonthWeekEndDate(formatedDate);

            }
            else
            {
                formatedDate = DateTime.Now;

                givenMontWeekStartDate = ValidationUtility.MonthWeekStartDate(formatedDate);

                montEndDate = ValidationUtility.MonthWeekEndDate(formatedDate);
            }

            ResponseDTO responseDTO = null;

            foreach (StoreDTO storeDTO in storeList)
            {
                ManagerBonusDTO managerBonusDTO = new ManagerBonusDTO();

                managerBonusDTO.StoreId = storeDTO.Id;
                managerBonusDTO.FirstDateOFMonth = givenMontWeekStartDate.Date;
                managerBonusDTO.LastDateOFMonth = montEndDate.Date.AddDays(6);
                managerBonusDTO.FoodCost = fCost;
                managerBonusDTO.LaborCost = lCost;
                managerBonusDTO.FoodLaborCost = foodLaborCost;
                managerBonusDTO.SalesIncrease = ValidationUtility.ToDouble(salesIncrease);
                managerBonusDTO.CustomerIndex = ValidationUtility.ToDouble(customerIndex);
                managerBonusDTO.CustomerComplaint = ValidationUtility.ToDouble(customerComplaint);
                managerBonusDTO.Catering = ValidationUtility.ToDouble(catering);
                managerBonusDTO.SubInspection = ValidationUtility.ToDouble(subInspection);

                ManagerBonusDTO zeroBasisDTO = managerBonusModel.GetZeroBasisList(managerBonusDTO.StoreId, managerBonusDTO.FirstDateOFMonth, managerBonusDTO.LastDateOFMonth);

                //if (!managerBonusModel.IsZeroBasisExist(managerBonusDTO))
                //{
                if (ValidationUtility.IsNull(zeroBasisDTO))
                {
                    managerBonusModel.AddBounus(managerBonusDTO, true);

                    responseDTO = new ResponseDTO { Error = "Success", Message = "Add Successfully" };

                }
                else
                {
                    responseDTO = new ResponseDTO { Error = "Error", Message = "Records Allready Exists Now you can Update Only" };
                }
            }

            return Json(responseDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult UpdatePaperworkList(string id, string ar, string paidOuts, string pettyExpense, string storeTransfer, string pfg1, string pfg2, string coke, string laborCost, string taxPercent, string nonTaxableSale)
        {
            WeeklyPaperworkModel weeklyPaperworkModel = new WeeklyPaperworkModel();

            GoalsModel goalsModel = new GoalsModel();

            string error = "";
            string msg = "";

            try
            {
                WeeklyPaperworkDTO weeklyPaperworkDTO = new WeeklyPaperworkDTO();
                weeklyPaperworkDTO.Id = ValidationUtility.ToInteger(id);

                weeklyPaperworkDTO.Ar = ValidationUtility.ToDouble(ar);
                weeklyPaperworkDTO.PaidOuts = ValidationUtility.ToDouble(paidOuts);
                weeklyPaperworkDTO.PettyExpense = ValidationUtility.ToDouble(pettyExpense);
                weeklyPaperworkDTO.StoreTransfer = ValidationUtility.ToDouble(storeTransfer);

                weeklyPaperworkDTO.Pfg1 = ValidationUtility.ToDouble(pfg1);
                weeklyPaperworkDTO.Pfg2 = ValidationUtility.ToDouble(pfg2);
                weeklyPaperworkDTO.Coke = ValidationUtility.ToDouble(coke);
                weeklyPaperworkDTO.LaborCost = ValidationUtility.ToDouble(laborCost);
                weeklyPaperworkDTO.TaxPercent = ValidationUtility.ToDouble(taxPercent);
                weeklyPaperworkDTO.NonTaxableSale = ValidationUtility.ToDouble(nonTaxableSale);

                weeklyPaperworkModel.UpdateWeeklyPaperSales(weeklyPaperworkDTO);

                weeklyPaperworkDTO = weeklyPaperworkModel.GetWeeklyPaperWorkOfWeek(ValidationUtility.ToInteger(id));

                ArrayList goalStoreList = new ArrayList();

               // ArrayList storeList = ValidationUtility.GetStoreList(true);

                ArrayList storeList = ValidationUtility.GetActiveStoreList(true);

                foreach (StoreDTO storDTO in storeList)
                {
                    if (storDTO.Id == weeklyPaperworkDTO.StoreId)
                    {
                        goalStoreList.Add(storDTO);
                        break;
                    }
                }

                if (!goalsModel.IsGoalsYTDCurrentYearRecordExist(weeklyPaperworkDTO.WeekStartDate, goalStoreList))
                {

                    ArrayList currentYTDList = goalsModel.GetCurrentWeekGoalsYTD(weeklyPaperworkDTO.WeekStartDate, goalStoreList);
                    goalsModel.AddGoalYTD(currentYTDList);
                }
                else
                {
                    goalsModel.UpdateCurrentYTD(weeklyPaperworkDTO);
                }

                error = "Success";
                msg = "Update Successfully";
            }
            catch (Exception ex)
            {
                error = "Error";
                msg = " Not Update ";
                log.Error("Exception in UpdatePaperworkList ", ex);

            }

            ResponseDTO resDTO = new ResponseDTO { Error = error, Message = msg };
            return Json(resDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult UpdateInActiveStore(string id, string storeName, string connectionString)
        {
            string error = "";
            string msg = "";
            try
            {
                StoreModel sm = new StoreModel();

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

                    StoreDTO dto = new StoreDTO();

                    dto.Id = sId;
                    dto.StoreName = storeName;
                    dto.ConnectionString = connectionString;
                    dto.IsActive = true;

                    sm.AddStore(dto);

                    error = "Success";
                    msg = "Store Connected Successfully";

                }
            }

            catch (Exception ex)
            {
                log.Error("Exception in UpdateInActiveStore method",ex);
                error = "Error";
                msg = " Store is not connected.";
            }

            ResponseDTO resDTO = new ResponseDTO { Error = error, Message = msg };
            return Json(resDTO, JsonRequestBehavior.AllowGet);
        }
        public JsonResult UpdateSheduleTime(string tId, string sIn, string sOut, string bDate)
        {
            ResponseDTO dto = null;

            int emplTrackerId = ValidationUtility.ToInteger(tId);

            EmployeeTrackerModel employeeTrackerModel = new EmployeeTrackerModel();

            DateTime formatedDate = ValidationUtility.ToDate(bDate);

            int inHour = 0;

            int inSecond = 0;

            if (sIn.Contains(":"))
            {
                string[] str = sIn.Split(':');

                if (sIn.ToLower().Contains("pm"))
                {
                    inHour = ValidationUtility.ToInteger(str[0]) + 12;

                    inSecond = ValidationUtility.ToInteger(str[1]);
                }
                else
                {

                    inHour = ValidationUtility.ToInteger(str[0]);

                    inSecond = ValidationUtility.ToInteger(str[1]);
                }
            }

            DateTime schedulInTime = new DateTime(formatedDate.Year, formatedDate.Month, formatedDate.Day, inHour, inSecond, 0);

            int outHour = 0;

            int outSecond = 0;

            string[] str1 = sOut.Split(':');

            if (sOut.Contains(":"))
            {
                if (sOut.ToLower().Contains("pm"))
                {

                    outHour = ValidationUtility.ToInteger(str1[0]) + 12;

                    outSecond = ValidationUtility.ToInteger(str1[1]);
                }
                else
                {
                    outHour = ValidationUtility.ToInteger(str1[0]);

                    outSecond = ValidationUtility.ToInteger(str1[1]);
                }

            }

            DateTime schedulOutTime = new DateTime(formatedDate.Year, formatedDate.Month, formatedDate.Day, outHour, outSecond, 0);

            if (schedulInTime.TimeOfDay >= schedulOutTime.TimeOfDay)
            {
                dto = new ResponseDTO { Error = "Error", Message = "Schedule In Time will not be greater then ScheduleOut Time Please Enter Correct Schedule" };
            }
            else
            {
                dto = new ResponseDTO { Error = "Success", Message = "Schedule Updated successfully" };

                employeeTrackerModel.UpdateSheduleDateTime(emplTrackerId, schedulInTime, schedulOutTime, formatedDate);
            }

            //

            return Json(dto, JsonRequestBehavior.AllowGet);

            // employeeTrackerModel.
        }