public async Task <bool> Handle(AddNewsCommand request, CancellationToken cancellationToken) { var news = new Domain.Entities.News(request.TextNews); await _db.News.AddAsync(news); await _db.SaveChangesAsync(); return(true); }
public ActionResult CreateNews(NewsViewModel model) { if (ModelState.IsValid) { //var browserName = Request["browserName"]; //if (browserName == "IE" || browserName == "Safari") //{ // // For normal Upload // // Save normal upload for Image // model.ImagePath = model.SourceFileImage != null ? FileHelper.SaveFile(model.SourceFileImage, Globals.UploadedFilePath) : newsRepository.GetImgPath(model.Id); // // Save normal upload for Thumbnail Image // model.ThumbnailPath = model.SourceFileThumbnailImage != null ? FileHelper.SaveFile(model.SourceFileThumbnailImage, Globals.UploadedFilePath) : newsRepository.GetThumbnailImgPath(model.Id); //} //else //{ // // For Image64String // // Save NormalImage // if (!string.IsNullOrEmpty(model.ImagePath64String)) // { // model.ImagePath = FileHelper.WriteFileFromBase64String(model.ImagePath64String, Globals.UploadedFilePath); // } // // Save ThumbnailImage // if (!string.IsNullOrEmpty(model.ThumbnailPath64String)) // { // model.ThumbnailPath = FileHelper.WriteFileFromBase64String(model.ThumbnailPath64String, Globals.UploadedFilePath); // } //} var newss = new Domain.Entities.News(); AutoMapper.Mapper.Map(model, newss); newss.CreatedUser = WebSecurity.CurrentUserId; newss.UpdateUser = WebSecurity.CurrentUserId; newss.CreatedDate = DateTime.Now; newss.ModifiedDate = DateTime.Now; newsRepository.InsertNews(newss); TempData["AlertMessage"] = App_GlobalResources.Wording.InsertSuccess; return(RedirectToAction("ListNews")); } model.ListCategory = categoryRepository.GetAllCategories(); return(View(model)); }
public ActionResult CreateNews() { News news = new Domain.Entities.News(); news.PublisTime = DateTime.Now; return View("EditNews", news); }