public void AddNewNotice(NoticeEntity notice) { using (var context = new UsersContext()) { context.Notices.Add(notice); context.SaveChanges(); } }
public void UpdateNotice(NoticeEntity noticeToUpdate) { using (var context = new UsersContext()) { var notice = context.Notices.FirstOrDefault(x => x.Id == noticeToUpdate.Id); notice.Amount = noticeToUpdate.Amount; notice.CategoryId = noticeToUpdate.CategoryId; notice.Description = noticeToUpdate.Description; notice.NoticePlaceId = noticeToUpdate.NoticePlaceId; notice.Title = noticeToUpdate.Title; context.SaveChanges(); } }