Beispiel #1
0
        public JsonResult DeleteMultiple(int[] array)
        {
            if (array == null)
            {
                return(Json(new {
                    valid = false,
                    Message = CustomMessages.ErrorMessage("Please provide coupons to be deleted"),
                    redirect = "none"
                }));
            }
            if (array.Length == 0)
            {
                return(Json(new {
                    valid = false,
                    Message = CustomMessages.ErrorMessage("Please provide coupons to be deleted"),
                    redirect = "none"
                }));
            }
            int deleted = _couponRepository.Delete(array);

            if (deleted == 0)
            {
                return(Json(new {
                    valid = false,
                    Message = CustomMessages.ErrorMessage("Coupons couldn't be deleted"),
                    redirect = "none"
                }));
            }
            return(Json(new {
                valid = true,
                Message = CustomMessages.SuccessMessage(array.Length + " coupons were deleted succesfully"),
                redirect = "/Coupon/AdminIndex"
            }));
        }
Beispiel #2
0
        public WrappedJsonResult EditAjax(tDeal dealData)
        {
            if (ModelState.IsValid)
            {
                ArrangeCityData(dealData);
                ArrangeImages(dealData);

                _dealRepository.InsertOrUpdate(dealData);
                return(new WrappedJsonResult {
                    Data = new {
                        objectAddedName = "",
                        valid = true,
                        Message = CustomMessages.SuccessMessage("tDeal Updated Succesfully")
                    }
                });
            }
            else
            {
                return(new WrappedJsonResult {
                    Data = new {
                        objectAddedName = "",
                        valid = false,
                        Message = CustomMessages.ErrorMessage("Fill All Fields please")
                    }
                });
            }
        }
Beispiel #3
0
 public JsonResult CreateAjax(tCoupon user, int Count)
 {
     if (ModelState.IsValid)
     {
         user.DateAdded = DateTime.Now;
         if (user.DateBegin < DateTime.Now)
         {
             return(Json(new {
                 objectAddedName = user.Code,
                 valid = false,
                 Message = CustomMessages.ErrorMessage("Beginning date must be greater than now...")
             }));
         }
         if (user.DateEnd < DateTime.Now)
         {
             return(Json(new {
                 objectAddedName = user.Code,
                 valid = false,
                 Message = CustomMessages.ErrorMessage("Expiration date must be greater than now...")
             }));
         }
         if (user.DateEnd <= user.DateBegin)
         {
             return(Json(new {
                 objectAddedName = user.Code,
                 valid = false,
                 Message = CustomMessages.ErrorMessage("Expiration date must follow Beginning Date")
             }));
         }
         if (Count <= 0)
         {
             return(Json(new {
                 objectAddedName = user.Code,
                 valid = false,
                 Message = CustomMessages.ErrorMessage("Count Must be greater than 0")
             }));
         }
         if (Count > 200)
         {
             return(Json(new {
                 objectAddedName = user.Code,
                 valid = false,
                 Message = CustomMessages.ErrorMessage("Count must be less than 200")
             }));
         }
         List <tCoupon> res = CreateCouponsMultiple(user, Count);
         _couponRepository.Insert(res);
         return(Json(new {
             objectAddedName = user.Code,
             valid = true,
             Message = CustomMessages.SuccessMessage("Coupons were added Succesfully")
         }));
     }
     return(Json(new {
         objectAddedName = "",
         valid = false,
         Message = CustomMessages.ErrorMessage("Fill All Fields please")
     }));
 }
Beispiel #4
0
 public WrappedJsonResult CreateAjax(tDeal dealData)
 {
     if (ModelState.IsValid)
     {
         ArrangeCityData(dealData);
         ArrangeImages(dealData);
         dealData.DateAdded = DateTime.Now;
         if (dealData.DateStarting < DateTime.Now)
         {
             return new WrappedJsonResult {
                        Data = new {
                            objectAddedName = dealData.DealTitle,
                            valid           = false,
                            Message         = CustomMessages.ErrorMessage("DateStarting must be greater than now...")
                        }
             }
         }
         ;
         if (dealData.DateEnding < DateTime.Now)
         {
             return new  WrappedJsonResult {
                        Data = new {
                            objectAddedName = dealData.DealTitle,
                            valid           = false,
                            Message         = CustomMessages.ErrorMessage("DateEnding must be greater than now...")
                        }
             }
         }
         ;
         if (dealData.DateEnding <= dealData.DateStarting)
         {
             return new WrappedJsonResult {
                        Data = new {
                            objectAddedName = dealData.DealTitle,
                            valid           = false,
                            Message         = CustomMessages.ErrorMessage("DateEnding must follow Beginning Date")
                        }
             }
         }
         ;
         _dealRepository.InsertOrUpdate(dealData);
         return(new WrappedJsonResult {
             Data = new {
                 objectAddedName = dealData.DealTitle,
                 valid = true,
                 Message = CustomMessages.SuccessMessage("Deal was added Succesfully")
             }
         });
     }
     return(new WrappedJsonResult {
         Data = new {
             objectAddedName = "",
             valid = false,
             Message = CustomMessages.ErrorMessage("Fill All Fields please")
         }
     });
 }
Beispiel #5
0
 public JsonResult DeleteMultiple(int[] array)
 {
     if (array == null)
     {
         return(Json(new {
             valid = false,
             Message = CustomMessages.ErrorMessage("Please provide deals to be deleted"),
             redirect = "none"
         }));
     }
     if (array.Length == 0)
     {
         return(Json(new {
             valid = false,
             Message = CustomMessages.ErrorMessage("Please provide deals to be deleted"),
             redirect = "none"
         }));
     }
     try
     {
         int deleted = _dealRepository.Delete(array);
         if (deleted == 0)
         {
             return(Json(new {
                 valid = false,
                 Message = CustomMessages.ErrorMessage("deals couldn't be deleted"),
                 redirect = "none"
             }));
         }
         return(Json(new {
             valid = true,
             Message = CustomMessages.SuccessMessage(array.Length + " deals were deleted succesfully"),
             redirect = "/Deal/AdminIndex"
         }));
     }
     catch (Exception ex)
     {
         return(Json(new {
             valid = false,
             Message = CustomMessages.ErrorMessage(array.Length + " deals couldn't be deleted : " + ex.Message),
             redirect = "/Deal/AdminIndex"
         }));
     }
 }
Beispiel #6
0
        public JsonResult GetCoupons(int?CouponType)
        {
            if (CouponType == null)
            {
                CouponType = (int)Enums.enmCoupontype.Usable;
            }
            List <tCoupon> couponList = new List <tCoupon>();

            if (CouponType == (int)Enums.enmCoupontype.Usable)
            {
                couponList = _couponRepository.GetCouponsUsable();
            }
            else if (CouponType == (int)Enums.enmCoupontype.Used)
            {
                couponList = _couponRepository.GetCouponsUsed();
            }
            else if (CouponType == (int)Enums.enmCoupontype.Expired)
            {
                couponList = _couponRepository.GetCouponsExpired();
            }
            else
            {
                return(Json(new {
                    valid = false,
                    Message = CustomMessages.ErrorMessage("Please provide CouponType"),
                    redirect = "none"
                }));
            }
            int i, n = couponList.Count;

            string[][] res = new string[n][];
            //res[0] = new string[n][];
            for (i = 0; i < n; i++)
            {
                //tCouponForAdminIndexJson obj = new tCouponForAdminIndexJson {
                //    Partner = couponList[i].tUser.UserName, Code = couponList[i].Code,
                //    CustomCode = couponList[i].CustomCode, CouponValue = couponList[i].CouponValue,
                //    DateBegin = couponList[i].DateBegin, DateEnd = couponList[i].DateEnd,
                //    DateAdded = couponList[i].DateAdded
                //};
                //tCouponForAdminIndexJson obj = new tCouponForAdminIndexJson();
                string[] str = new string[10];
                str[0] = "<input type=\"checkbox\" />";
                str[1] = couponList[i].IDCoupon.ToString();
                str[2] = couponList[i].tUser.UserName;
                str[3] = couponList[i].Code;
                str[4] = couponList[i].CustomCode;
                str[5] = couponList[i].CouponValue.ToString();
                str[6] = couponList[i].DateBegin.ToString("dd.MM.yyyy");
                str[7] = couponList[i].DateEnd.ToString("dd.MM.yyyy");
                str[8] = couponList[i].DateAdded.ToString("dd.MM.yyyy");
                string lnkDelete = "";
                if (CouponType == (int)aGrouponClasses.Utils.Enums.enmCoupontype.Usable || CouponType == (int)aGrouponClasses.Utils.Enums.enmCoupontype.Expired)
                {
                    lnkDelete = "<a name=\"RowDelete\" onclick=\"PrepareDelete(this);return false;\" href=\"#\">Delete</a>";
                }
                str[9] = lnkDelete;
                res[i] = str;
            }
            return(Json(new {
                aaData = res
            }, JsonRequestBehavior.AllowGet));
        }