public ActionResult Index(DealModels newDeal) { if (ModelState.IsValid) { newDeal.City = dbHelper.GetCityByUrlName(newDeal.City.Name); newDeal.City.CityId = dbHelper.GetCityByUrlName(newDeal.City.UrlName).CityId; // user not specified start and end date if (newDeal.StartDate.Year == 1 || newDeal.EndDate.Year == 1) { newDeal.StartDate = DateTime.Now; newDeal.EndDate = DateTime.Now + new TimeSpan(5,0,0); } // image is from harddrive if (newDeal.PhotoUrl == null) { newDeal.PhotoUrl = "../../uploads/defaultPhoto.png"; } else if(!newDeal.PhotoUrl.StartsWith("http://")) { newDeal.PhotoUrl = "../../uploads/" + newDeal.PhotoUrl; } if (HttpContext.User.Identity.IsAuthenticated) { newDeal.User = dbHelper.GetUser(HttpContext.User.Identity.Name); } dbHelper.AddDealsToValidated(newDeal); } return View("_DodanoOferte"); }
public bool AddDealsToValidated(DealModels deal) { try { var nDeal = ConvertNotValidatedDeal(deal); dbStore.NotValidatedDeal.Add(nDeal); dbStore.SaveChange(); return true; } catch (Exception e) { throw e; } return false; }
public bool AddDealsToMainList(DealModels deal) { try { deal.AddedDate = DateTime.Now; dbStore.Entry(deal).State = EntityState.Modified; dbStore.Deal.Add(deal); dbStore.SaveChanges(); dbStore = new RazemTaniejEntities(); return true; } catch (Exception e) { throw e; } return false; }
private DealModels CopyDeal(DealModels deal) { var copy = new DealModels { AddedDate = deal.AddedDate, Category = deal.Category, City = deal.City, Comments = deal.Comments, CommercialNetworks = deal.CommercialNetworks, Description = deal.Description, EndDate = deal.EndDate, Expired = deal.Expired, Forum = deal.Forum, NumberOfComments = deal.NumberOfComments, PhotoUrl = deal.PhotoUrl, Prize = deal.Prize, Quality = deal.Quality, Rank = deal.Rank, StartDate = deal.StartDate, Title = deal.Title, UrlDeal = deal.UrlDeal, User = deal.User }; return copy; }
/// <summary> /// Testuje daty /// </summary> /// <param name="deals"></param> /// <returns></returns> public bool Test1_A(IEnumerable<DealModels> deals) { var query = dbHelper.GetDealsBasicView(deals); DealModels oldItem = new DealModels { StartDate = new DateTime(2055,10,10,10,10,10) }; foreach (var item in query) { if (item.StartDate.Ticks < oldItem.StartDate.Ticks) { oldItem = item; } else { return false; } } return true; }
public void IncrementDealComments(DealModels deal) { deal.NumberOfComments = deal.NumberOfComments + 1; }
public bool EditDeal(DealModels deal) { try { dbStore.Deal.Add(deal); RemoveValidatedDeal(deal.DealId); dbStore.SaveChanges(); } catch (Exception e) { //TODO ? return false; } return true; }
public DealModels ConvertNotValidatedDeal(NotValidatedDealModels deal) { var newDeal = new DealModels { AddedDate = DateTime.Now, Category = deal.Category, City = deal.City, Comments = deal.Comments, CommercialNetworks = deal.CommercialNetworks, Description = deal.Description, EndDate = deal.EndDate, Expired = deal.Expired, Forum = deal.Forum, NumberOfComments = deal.NumberOfComments, PhotoUrl = deal.PhotoUrl, Prize = deal.Prize, Quality = deal.Quality, StartDate = deal.StartDate, Title = deal.Title, UrlDeal = deal.UrlDeal, User = deal.User, Rank = deal.Rank }; return newDeal; }
public bool CheckIfUserRankedDealBefore(DealModels deal, UserModels user) { var query = from p in user.RankedDeals where p == deal select p; if (query.Count() == 0) { return false; } return true; }
public void AddPositiveMark(DealModels deal, UserModels user) { deal.Rank = deal.Rank + 1; user.RankedDeals.Add(deal); dbStore.SaveChanges(); }
public ActionResult Index() { var newDeal = new DealModels(); ToolUtils._lastUrl = "../DodajOferte"; return View(newDeal); }
public ActionResult ValidatedItem(DealModels deal) { dbHelper.EditDeal(deal); return RedirectToAction("Index", "Administrator"); }
public ActionResult Index(DealModels deal) { dbHelper.AddDealsToValidated(deal); return RedirectToAction("Index", "Administrator"); }