public void EditAdvert(AdvertEditViewModel advertViewModel) { Advert advert = Adverts.FirstOrDefault(a => a.AdvertId == advertViewModel.AdvertId); mapper.Map(advertViewModel, advert); context.SaveChanges(); }
public void CreateAdvert(AdvertCreateViewModel advertViewModel, string userId) { Advert advert = mapper.Map <Advert>(advertViewModel); advert.AppUserId = userId; context.Adverts.Add(advert); context.SaveChanges(); }
public void DeleteAdvert(int advertId) { Advert dbEntry = Adverts.FirstOrDefault(a => a.AdvertId == advertId); if (dbEntry != null) { context.Adverts.Remove(dbEntry); context.SaveChanges(); } }