コード例 #1
0
        public void EditAdvert(AdvertEditViewModel advertViewModel)
        {
            Advert advert = Adverts.FirstOrDefault(a => a.AdvertId == advertViewModel.AdvertId);

            mapper.Map(advertViewModel, advert);

            context.SaveChanges();
        }
コード例 #2
0
        public void CreateAdvert(AdvertCreateViewModel advertViewModel, string userId)
        {
            Advert advert = mapper.Map <Advert>(advertViewModel);

            advert.AppUserId = userId;
            context.Adverts.Add(advert);
            context.SaveChanges();
        }
コード例 #3
0
        public void DeleteAdvert(int advertId)
        {
            Advert dbEntry = Adverts.FirstOrDefault(a => a.AdvertId == advertId);

            if (dbEntry != null)
            {
                context.Adverts.Remove(dbEntry);
                context.SaveChanges();
            }
        }