public void DeleteCategory(int photoId) { using (var model = new PhotoBEntities()) { var photo = model.Photos.FirstOrDefault(x => x.Id == photoId); if (photo != null) { model.Photos.Remove(photo); model.SaveChanges(); } } }
public void DeleteCategory(int categoryId) { using (var model = new PhotoBEntities()) { var category = model.Categories.FirstOrDefault(x => x.Id == categoryId); if (category != null) { model.Categories.Remove(category); } model.SaveChanges(); } }
public void UpdateCategory(CategoryVm categoryVm) { using (var model = new PhotoBEntities()) { var category = model.Categories.FirstOrDefault(x => x.Id == categoryVm.Id); if (category != null) { category.Name = categoryVm.Name; category.Description = categoryVm.Description; category.LastChangedBy = "System"; category.LastChanged = DateTime.Now; } model.SaveChanges(); } }
public void EditCategory(CategoryVm categoryVm) { using (var model = new PhotoBEntities()) { var category = new Category { Name = categoryVm.Name, Description = categoryVm.Description, LastChangedBy = "System", LastChanged = DateTime.Now }; model.Categories.Add(category); model.SaveChanges(); } }
public void Updatephoto(PhotoVm photoVm) { using (var model = new PhotoBEntities()) { var photo = model.Photos.FirstOrDefault(x => x.Id == photoVm.Id); if (photo != null) { photo.Name = photoVm.Name; photo.Number = photoVm.Number; photo.CategoryId = photoVm.CategoryId.Value; photo.Price = photoVm.Price.Value; photo.ImagePath = photoVm.ImagePath; photo.Author = photoVm.Author; photo.LastChangedBy = "System"; photo.LastChanged = DateTime.Now; } model.SaveChanges(); } }
public void EditPhoto(PhotoVm photoVm) { using (var model = new PhotoBEntities()) { var photo = new Photo { Name = photoVm.Name, Number = photoVm.Number, CategoryId = photoVm.CategoryId.Value, Price = photoVm.Price.Value, ImagePath = photoVm.ImagePath, DateListed = DateTime.Now, Author = photoVm.Author, LastChangedBy = "System", LastChanged = DateTime.Now }; model.Photos.Add(photo); model.SaveChanges(); } }