public async Task<ActionResult> Edit(AnnouncementViewModel announcementModel) { var selectedAnnouncement = await _announcementService.Find(announcementModel.Id); selectedAnnouncement.SmsText = announcementModel.SmsText; selectedAnnouncement.Title = announcementModel.Title; selectedAnnouncement.WebsiteText = announcementModel.WebsiteText; selectedAnnouncement.EmailText = announcementModel.EmailText; selectedAnnouncement.CreatedDate = DateTime.Now; selectedAnnouncement.HasSms = announcementModel.HasSms; selectedAnnouncement.HasEmail = announcementModel.HasEmail; await _dbContext.SaveChangesAsync(); return new HttpStatusCodeResult(HttpStatusCode.OK); }
public async Task<ActionResult> Add(AnnouncementViewModel announcementModel) { var announcement = new DomainClasses.Announcement() { EmailText = announcementModel.EmailText, SmsText = announcementModel.SmsText, Title = announcementModel.Title, WebsiteText = announcementModel.WebsiteText.ToSafeHtml(), CompetitionId = announcementModel.CompetitionId, CreatedDate = DateTime.Now, HasEmail = announcementModel.HasEmail, HasSms = announcementModel.HasSms }; _announcementService.Add(announcement); await _dbContext.SaveChangesAsync(); return new HttpStatusCodeResult(HttpStatusCode.OK); }