Пример #1
0
 public VegCategoryVM(VegCategoryDTO row)
 {
     Id          = row.Id;
     Name        = row.Name;
     Description = row.Description;
     Image       = row.Image;
 }
 public VegCategoryVM Delete(VegCategoryVM model)
 {
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         VegCategoryDTO dto = db.VegCategories.Find(model.Id);
         db.VegCategories.Remove(dto);
         db.SaveChanges();
     }
     return(null);
 }
 public VegCategoryVM Put(VegCategoryVM model)
 {
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         VegCategoryDTO dto = db.VegCategories.Find(model.Id);
         dto.Name        = model.Name;
         dto.Description = model.Description;
         db.SaveChanges();
     }
     return(model);
 }
        public VegCategoryVM Post(VegCategoryVM model)
        {
            VegCategoryDTO dto = new VegCategoryDTO();

            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                dto.Name        = model.Name;
                dto.Description = model.Description;
                dto.Image       = model.Image;
                db.VegCategories.Add(dto);
                db.SaveChanges();
            }
            //_DbContext.SaveChanges();
            return(new VegCategoryVM(dto));
        }