Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
 partial void DeletetCategory(tCategory instance);
Exemplo n.º 3
0
 partial void UpdatetCategory(tCategory instance);
Exemplo n.º 4
0
 partial void InserttCategory(tCategory instance);
Exemplo n.º 5
0
		private void detach_tCategories(tCategory entity)
		{
			this.SendPropertyChanging();
			entity.tGroup = null;
		}
Exemplo n.º 6
0
		private void attach_tCategories(tCategory entity)
		{
			this.SendPropertyChanging();
			entity.tCategoryType = this;
		}
Exemplo n.º 7
0
 public ActionResult Select(tCategory selectedCat)
 {
     MembershipHelper.CurrentCity = selectedCat;
     return RedirectToAction("Index", "Home");
 }
Exemplo n.º 8
0
 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"
         });
     }
 }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
        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);
        }