public static string GetLeftTSStrForDeal(tDeal deal) { if (deal.DateEnding < DateTime.Now) return "Deal Is Over"; TimeSpan ts = deal.DateEnding - DateTime.Now; return ts.Days + " days " + ts.Hours + " hrs " + ts.Minutes + " min " + ts.Seconds + " sec"; }
public static string DiscountStr(tDeal deal) { decimal currPrice = deal.DealPrice; decimal marketPrice = deal.MarketPrice; decimal discount = 100 - ((currPrice*100)/marketPrice); discount = Math.Ceiling(discount); return String.Format("{0:0.##} %", discount); }
partial void InserttDeal(tDeal instance);
private void detach_tDeals(tDeal entity) { this.SendPropertyChanging(); entity.tGroup = null; }
private void attach_tDeals(tDeal entity) { this.SendPropertyChanging(); entity.tGroup = this; }
public static bool DealIsActive(tDeal deal) { if (deal.DateEnding < DateTime.Now) return false; return true; }
private void ValidateDeal(tDeal currentDeal) { if (currentDeal == null) { ModelState.AddModelError("DealInfo", "Deal Info couldn't be found, please contact web admin"); } if (DateTime.Now < currentDeal.DateStarting) { ModelState.AddModelError("DealInfo", "Deal has not started yet."); } if (DateTime.Now > currentDeal.DateEnding) { ModelState.AddModelError("DealInfo", "Deal is over."); } //if (currentCheckoutData.Quantity > currentDeal.LimitUpper) { // resModel.PaymentStatus = false; // resModel.StatusMessage += "Maximum Amount allowed :" + currentDeal.LimitUpper; // return View(resModel); //} //if (currentCheckoutData.Quantity < currentDeal.LimitLower) { // resModel.PaymentStatus = false; // resModel.StatusMessage += "Minimum Amount allowed :" + currentDeal.LimitUpper; // return View(resModel); //} }
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") }}; }
decimal CalculateAmountToBePaid(tDeal deal, int Amount) { return deal.DealPrice * Amount; }
private tDealBuyModel GetBuyModel(tDeal currentDeal) { tDealBuyModel buyModel = new tDealBuyModel(); buyModel.currentDeal = currentDeal; buyModel.Quantity = CommonUtils.Instance.ShoppingCart.Quantity; buyModel.BuyerNotes = CommonUtils.Instance.ShoppingCart.BuyerNotes; buyModel.MobilePhone = CommonUtils.Instance.ShoppingCart.MobilePhone; return buyModel; }
private void ArrangeImages(tDeal dealData) { HttpPostedFileBase ProductImage = Request.Files["ProductImage"]; HttpPostedFileBase ProductImage1 = Request.Files["ProductImage1"]; HttpPostedFileBase ProductImage2 = Request.Files["ProductImage2"]; if (ProductImage.ContentLength > 0) { var fileName = Path.GetFileName(ProductImage.FileName); var path = Path.Combine(Server.MapPath("~/Images/Deal"), fileName); ProductImage.SaveAs(path); dealData.ProductImage = fileName; } if (ProductImage1.ContentLength > 0) { var fileName = Path.GetFileName(ProductImage1.FileName); var path = Path.Combine(Server.MapPath("~/Images/Deal"), fileName); ProductImage1.SaveAs(path); dealData.ProductImage1 = fileName; } if (ProductImage2.ContentLength > 0) { var fileName = Path.GetFileName(ProductImage2.FileName); var path = Path.Combine(Server.MapPath("~/Images/Deal"), fileName); ProductImage2.SaveAs(path); dealData.ProductImage2 = fileName; } }
private void ArrangeCityData(tDeal dealData) { if (dealData.HelperString != null) { string[] arr = dealData.HelperString.Split(','); if (arr.Length > 0) { int[] intArr = new int[arr.Length]; for (int i = 0; i < intArr.Length; i++) { dealData.tDealCities.Add(new tDealCity { IDCity = int.Parse(arr[i]), IDDeal = dealData.IDDeal }); } } dealData.HelperString = null; } }
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") } }; } }
partial void UpdatetDeal(tDeal instance);
public void InsertOrUpdate(tDeal user) { if (user.IDDeal == default(int)) { // New entity user.DateAdded = DateTime.Now; context.tDeals.InsertOnSubmit(user); } else { // Existing entity tDeal userToUpdate = Find(user.IDDeal); if (userToUpdate != null && userToUpdate.IDDeal > 0) { userToUpdate.AllowRefundFlag = user.AllowRefundFlag; userToUpdate.BiggestCardUse = user.BiggestCardUse; userToUpdate.ConsumerRebates = user.ConsumerRebates; userToUpdate.DateCouponExpiry = user.DateCouponExpiry; userToUpdate.DateEnding = user.DateEnding; if (userToUpdate.tDealCities.Count > 0) { for (int i = 0; i < userToUpdate.tDealCities.Count; i++) { context.tDealCities.DeleteOnSubmit(userToUpdate.tDealCities[i]); } context.SubmitChanges(); userToUpdate.tDealCities = user.tDealCities; } userToUpdate.DateStarting = user.DateStarting; userToUpdate.DealPrice = user.DealPrice; userToUpdate.DealTitle = user.DealTitle; userToUpdate.Detail = user.Detail; userToUpdate.FlvVideoFile = user.FlvVideoFile; userToUpdate.IDDealCategory = user.IDDealCategory; userToUpdate.IDDealType = user.IDDealType; userToUpdate.IDGroup = user.IDGroup; userToUpdate.IDPartner = user.IDPartner; userToUpdate.Introduction = user.Introduction; userToUpdate.InvitationRebate = user.InvitationRebate; userToUpdate.LimitLower = user.LimitLower; userToUpdate.LimitUpper = user.LimitUpper; userToUpdate.LimitUser = user.LimitUser; userToUpdate.MarketPrice = user.MarketPrice; userToUpdate.ModeOfDelivery = user.ModeOfDelivery; userToUpdate.PrductName = user.PrductName; userToUpdate.ProductImage = user.ProductImage; userToUpdate.ProductImage1 = user.ProductImage1; userToUpdate.ProductImage2 = user.ProductImage2; userToUpdate.ProductOptions = user.ProductOptions; userToUpdate.QuantityMinimum = user.QuantityMinimum; userToUpdate.SortOrder = user.SortOrder; userToUpdate.Tips = user.Tips; userToUpdate.UserReviews = user.UserReviews; userToUpdate.VirtualBuyers = user.VirtualBuyers; } } context.SubmitChanges(); }
partial void DeletetDeal(tDeal instance);
public ActionResult Index() { if (MembershipHelper.CurrentCity == null || MembershipHelper.CurrentCity.IDCategory==0) { tCategory cat = _categoryRepository.GetListByIDCategoryType((int)Enums.enmCategoryTypes.City). FirstOrDefault(); if (cat == null) cat = new tCategory() { Name = "City Not Found", IDCategory = 0 }; MembershipHelper.CurrentCity = cat; } tDeal currentDeal = _dealRepository.GetLatestDeal(MembershipHelper.CurrentCity.IDCategory); ViewBag.LeftTSStr = tDealUtils.GetLeftTSStrForDeal(currentDeal); if (currentDeal == null) currentDeal = new tDeal(); if (MembershipHelper.CurrentCity != null && currentDeal!=null) ViewBag.DealsBySameCategory = _dealRepository.GetListByIDCategory(currentDeal.IDDealCategory).Take(6).OrderByDescending(t=>t.DateAdded).ToList(); else ViewBag.DealsBySameCategory = new List<tDeal>(); return View(currentDeal); }