Ejemplo n.º 1
0
        public ActionResult AddSearch(AddEditSearchVM vm)
        {
            profileData = AuthCookies.DeserializeCookie<UserProfileSessionData>(HttpContext.Request.Cookies["authenticationToken"]);
            try
            {
                if (ModelState.IsValid)
                {
                    SearchCriteria sc = new SearchCriteria
                    {
                        ProfileId = profileData.ProfileId,
                        SearchText = vm.SearchText,
                        MinPrice = vm.MinPrice,
                        MaxPrice = vm.MaxPrice,
                    };

                    db.AddEntry(sc);

                    List<CategorySearch> catSearch = new List<CategorySearch>();
                    foreach (CheckBoxCategoryVM c in vm.Categories.Where(w => w.IsChecked))
                    {
                        string http = RssPages.BuildHttp(vm, c.Code, profileData.City);
                        catSearch.Add(new CategorySearch { SearchId = sc.SearchId, Category = c.Code, SearchLink = http });
                    }

                    db.AddEntries(catSearch);
                }
            }
            catch (RetryLimitExceededException)
            {
                ModelState.AddModelError("", "Unable to save changes. Please try again. If the same error keeps occurring, try again another time.");
            }

            return RedirectToAction("Index");
        }
Ejemplo n.º 2
0
 public static void DeleteEntry(this CLContext db, SearchCriteria sc)
 {
     db.SearchCriteria.Remove(sc);
     db.SaveChanges();
 }
Ejemplo n.º 3
0
 public static void AddEntry(this CLContext db, SearchCriteria sc)
 {
     db.SearchCriteria.Add(sc);
     db.SaveChanges();
 }