Пример #1
0
 partial void DeletetCoupon(tCoupon instance);
Пример #2
0
 partial void InserttCoupon(tCoupon instance);
Пример #3
0
 partial void UpdatetCoupon(tCoupon instance);
Пример #4
0
		private void detach_tCoupons(tCoupon entity)
		{
			this.SendPropertyChanging();
			entity.tUser = null;
		}
Пример #5
0
		private void attach_tCoupons(tCoupon entity)
		{
			this.SendPropertyChanging();
			entity.tUser = this;
		}
Пример #6
0
        private List<tCoupon> CreateCouponsMultiple(tCoupon user, int Count)
        {
            List<tCoupon> res = new List<tCoupon>();
            for (int i = 0; i < Count; i++) {

                string Finalcode = GenerateRandomCode(16);

                tCoupon couponToCreate = new tCoupon();
                couponToCreate.IDPartner = user.IDPartner;
                couponToCreate.Code = user.Code;
                couponToCreate.CustomCode = Finalcode;
                couponToCreate.CouponValue = user.CouponValue;
                couponToCreate.DateBegin = user.DateBegin;
                couponToCreate.DateEnd = user.DateEnd;
                couponToCreate.DateAdded = user.DateAdded;
                couponToCreate.CouponStatus = (int) Enums.enmCouponStatus.Unused;
                res.Add(couponToCreate);
            }
            return res;
        }
Пример #7
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")
     });
 }
Пример #8
0
 public void InsertOrUpdate(tCoupon user)
 {
     if (user.IDCoupon == default(int)) {
         // New entity
         context.tCoupons.InsertOnSubmit(user);
     } else {
         // Existing entity
         tCoupon userToUpdate = Find(user.IDCoupon);
         if (userToUpdate != null && userToUpdate.IDCoupon > 0) {
             userToUpdate.IDPartner = user.IDPartner;
             userToUpdate.Code = user.Code;
             userToUpdate.CouponValue = user.CouponValue;
             userToUpdate.DateBegin = user.DateBegin;
             userToUpdate.DateEnd = user.DateEnd;
             userToUpdate.DateAdded = user.DateAdded;
             userToUpdate.CouponStatus = user.CouponStatus;
             userToUpdate.ConsumeStatus = user.ConsumeStatus;
         }
     }
 }