public void InsertOrUpdate(tCategory user) { if (user.InitialLetter.Length > 1) user.InitialLetter = user.InitialLetter.Substring(0, 1); if (user.IDCategory == default(int)) { // New entity context.tCategories.InsertOnSubmit(user); } else { // Existing entity //context.USERs.Attach(user); //context.Entry(user).State = EntityState.Modified; tCategory userToUpdate = Find(user.IDCategory); if (userToUpdate != null && userToUpdate.IDCategory > 0) { userToUpdate.IDCategoryType = user.IDCategoryType; userToUpdate.IDGroup = user.IDGroup; userToUpdate.InitialLetter = user.InitialLetter; userToUpdate.Slug = user.Slug; userToUpdate.Sort = user.Sort; userToUpdate.Name = user.Name; userToUpdate.DisplayFlag = user.DisplayFlag; } } context.SubmitChanges(); }
partial void DeletetCategory(tCategory instance);
partial void UpdatetCategory(tCategory instance);
partial void InserttCategory(tCategory instance);
private void detach_tCategories(tCategory entity) { this.SendPropertyChanging(); entity.tGroup = null; }
private void attach_tCategories(tCategory entity) { this.SendPropertyChanging(); entity.tCategoryType = this; }
public ActionResult Select(tCategory selectedCat) { MembershipHelper.CurrentCity = selectedCat; return RedirectToAction("Index", "Home"); }
public JsonResult EditAjax(tCategory city) { if (ModelState.IsValid) { _categoryRepository.InsertOrUpdate(city); return Json(new { objectAddedName = city.Name, valid = true, Message = "Category was updated Succesfully" }); } else { return Json(new { objectAddedName = "", valid = false, Message = "Fill All Fields please" }); } }
public ActionResult CitySelector() { tCategory cat = _categoryRepository.Find(MembershipHelper.CurrentCity.IDCategory); List<tCategory> cats = _categoryRepository.GetListByIDCategoryType((int) Enums.enmCategoryTypes.City); ViewBag.catData = cats; if (cat == null) { cat = cats.FirstOrDefault(); } if (cat == null) cat = new tCategory() { Name = "City Not Found", IDCategory = 0 }; return PartialView(cat); }
public ActionResult DealsByCategory(int? IDCity) { tCategory cat; if (IDCity == null) IDCity = 1; cat = _categoryRepository.Find((int)IDCity); if (cat == null) cat = new tCategory(); List<tDeal> deals = _dealRepository.GetListByCity((int)IDCity).OrderByDescending(t=>t.DateAdded).ToList(); tDealFrontEndModel model = new tDealFrontEndModel(); model.currentCat = cat; model.currentDeals = deals; return View(model); }
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); }