示例#1
0
        public ActionResult BrandDelete(long brandId)
        {
            CT_BRAND deletedBrand = repository.DeleteBrand(brandId);

            if (deletedBrand != null)
            {
                TempData["message"] = string.Format("{0} был удален", deletedBrand.Code);
            }
            return(RedirectToAction("Brands"));
        }
示例#2
0
        public CT_BRAND DeleteBrand(long brandId)
        {
            CT_BRAND dbEntry = context.CT_BRAND.Where(x => x.BrandId == brandId).Single();

            if (dbEntry != null)
            {
                context.CT_BRAND.Remove(dbEntry);
                context.SaveChanges();
            }
            return(dbEntry);
        }
示例#3
0
 public ActionResult BrandEdit(CT_BRAND brand)
 {
     if (ModelState.IsValid)
     {
         repository.SaveBrand(brand);
         TempData["message"] = string.Format("{0} сохранено", brand.Code);
         return(RedirectToAction("Brands"));
     }
     else
     {
         // что-то не так с значениями данных (there is something wrong with the data values)
         return(View(brand));
     }
 }
示例#4
0
 public void SaveBrand(CT_BRAND brand)
 {
     brand.DateLoad = DateTime.Now;
     if (brand.BrandId == 0)
     {
         context.CT_BRAND.Add(brand);
     }
     else
     {
         CT_BRAND dbEntry = context.CT_BRAND.Where(x => x.BrandId == brand.BrandId).Single();
         if (dbEntry != null)
         {
             dbEntry.Code     = brand.Code;
             dbEntry.Name     = brand.Name;
             dbEntry.DateLoad = brand.DateLoad;
         }
     }
     context.SaveChanges();
 }
示例#5
0
        public ViewResult BrandEdit(long brandId)
        {
            CT_BRAND brand = repository.Brands.Where(x => x.BrandId == brandId).FirstOrDefault();

            return(View(brand));
        }