示例#1
0
        public ActionResult MdlDelete(long modelId)
        {
            SK_MODEL deletedModel = repository.DeleteModel(modelId);

            if (deletedModel != null)
            {
                TempData["message"] = string.Format("{0} был удален", deletedModel.Code);
            }
            return(RedirectToAction("Mdls"));
        }
示例#2
0
        public SK_MODEL DeleteModel(long modelId)
        {
            SK_MODEL dbEntry = context.SK_MODEL.Where(x => x.ModelId == modelId).Single();

            if (dbEntry != null)
            {
                context.SK_MODEL.Remove(dbEntry);
                context.SaveChanges();
            }
            return(dbEntry);
        }
示例#3
0
        public ViewResult MdlEdit(long modelId)
        {
            SK_MODEL mdl = repository.Models.Where(x => x.ModelId == modelId).FirstOrDefault();
            IEnumerable <CT_BRAND> brands = repository.Brands;

            var mdlVM = new MdlViewModel
            {
                Mdl    = mdl,
                Brands = brands
            };

            return(View(mdlVM));
        }
示例#4
0
 public void SaveModel(SK_MODEL mdl)
 {
     mdl.DateLoad = DateTime.Now;
     if (mdl.ModelId == 0)
     {
         context.SK_MODEL.Add(mdl);
     }
     else
     {
         SK_MODEL dbEntry = context.SK_MODEL.Where(x => x.ModelId == mdl.ModelId).Single();
         if (dbEntry != null)
         {
             dbEntry.BrandId  = mdl.BrandId;
             dbEntry.Code     = mdl.Code;
             dbEntry.Name     = mdl.Name;
             dbEntry.CT_BRAND = mdl.CT_BRAND;
             dbEntry.DateLoad = mdl.DateLoad;
         }
     }
     context.SaveChanges();
 }