public async Task <IActionResult> Update([FromBody] UpdateContentViewModel model) { var grain = this._client.GetGrain <IManageContentGrain>(model.ContentId); var result = await grain.UpdateContent(model); return(Json(result)); }
public IActionResult UpdateContent(UpdateContentViewModel model) { var post = this._context.Posts.FirstOrDefault(p => p.Id == model.PostId); if (post != null) { post.Description = model.Description; post.Timestamp = DateTime.UtcNow; this._context.Posts.Update(post); this._context.SaveChanges(); } return(RedirectToAction("Index")); }
public IActionResult UpdateContent(UpdateContentViewModel model) { var faq = this._context.Faqs.FirstOrDefault(f => f.Id == model.FaqId); if (faq != null) { faq.Answer = model.Answer; faq.Timestamp = DateTime.UtcNow; this._context.Faqs.Update(faq); this._context.SaveChanges(); } return(RedirectToAction("Index")); }
public IActionResult UpdateContent(UpdateContentViewModel model) { var thread = this._context.Threads.FirstOrDefault(t => t.Id == model.ThreadId); if (thread != null) { thread.Content = model.Content; thread.Timestamp = DateTime.UtcNow; this._context.Threads.Update(thread); this._context.SaveChanges(); } return(RedirectToAction("Index")); }
public IActionResult UpdateContent(UpdateContentViewModel model) { var achiever = this._context.Achievers.FirstOrDefault(t => t.Id == model.AchieverId); if (achiever != null) { achiever.Content = model.Content; achiever.Timestamp = DateTime.UtcNow; this._context.Achievers.Update(achiever); this._context.SaveChanges(); } return(RedirectToAction("Index")); }
public IActionResult UpdateContent(UpdateContentViewModel model) { var schoolevent = this._context.SchoolEvents.FirstOrDefault(t => t.Id == model.SchoolEventId); if (schoolevent != null) { schoolevent.Content = model.Content; schoolevent.Timestamp = DateTime.UtcNow; this._context.SchoolEvents.Update(schoolevent); this._context.SaveChanges(); } return(RedirectToAction("Index")); }
public async Task <string> UpdateContent(UpdateContentViewModel model) { var content = await _context.Set <Content>() .Include(x => x.ContentVersions) .FirstOrDefaultAsync(x => x.Id == model.ContentId); content.AddContentVersion(model.TextContent); var result = _context.Update(content); await _context.SaveChangesAsync(); return(result.Id); }
public IActionResult UpdateContent(UpdateContentViewModel model) { var course = this._context.Courses.FirstOrDefault(p => p.Id == model.CourseId); if (course != null) { course.Content = model.Content; course.Timestamp = DateTime.UtcNow; this._context.Courses.Update(course); this._context.SaveChanges(); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Update(int id) { Console.WriteLine(id); var content = await _contentManager.GetById(id); var categories = await _categoryManager.GetAll(); UpdateContentViewModel model = new UpdateContentViewModel { Content = content, Categories = categories }; return(View(model)); }
public IActionResult UpdateContent(UpdateContentViewModel model) { var pollquestion = this._context.PollQuestions.FirstOrDefault(p => p.Id == model.PollQuestionId); if (pollquestion != null) { pollquestion.Content = model.Content; pollquestion.Timestamp = DateTime.UtcNow; this._context.PollQuestions.Update(pollquestion); this._context.SaveChanges(); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Update(UpdateContentViewModel model) { if (ModelState.IsValid) { var dbModel = _queryDispatcher.Dispatch <DtoUpdateContent>(new GetContentQuery() { ContentId = model.Id }); var authResult = await _authorizationService.AuthorizeAsync(User, dbModel , "WriterAndEditors"); if (authResult.Succeeded) { var result = _commandDispatcher.Dispatch(new EditContentCommand() { Title = model.Title, Description = model.Description, Body = model.Body, Rate = model.Rate, PublishDate = model.PublishDate, Id = model.Id, PhotoId = model.PhotoId, CategoryId = model.CategoryId, KeywordsId = model.KeywordsId, publishPlacesId = model.PublishPlacesId, }); if (result.IsSuccess) { return(RedirectToAction(nameof(List))); } AddCommadErrorsToModelState(result); } else { return(RedirectToAction("AccessDenied", "Account")); } } model.AllCategories = _queryDispatcher.Dispatch <List <Category> >(new GetCategoriesQuery()); model.AllKeywords = _queryDispatcher.Dispatch <List <Keyword> >(new GetKeywordsQuery()); model.AllPublishPlaces = _queryDispatcher.Dispatch <List <PublishPlace> >(new GetPlacesQuery()); model.PublishPlacesId = new List <long>(); model.KeywordsId = new List <long>(); return(View(model)); }
public async Task <IActionResult> Update(long id) { var viewModel = new UpdateContentViewModel(); var model = _queryDispatcher.Dispatch <DtoUpdateContent>(new GetContentQuery() { ContentId = id }); if (model == null) { return(View(model)); } var authResult = await _authorizationService.AuthorizeAsync(User, model , "WriterAndEditors"); if (authResult.Succeeded) { viewModel.Title = model.Title; viewModel.Description = model.Description; viewModel.Body = model.Body; viewModel.Rate = model.Rate; viewModel.PublishDate = model.PublishDate; viewModel.WriterName = model.WriterName; viewModel.Id = model.Id; viewModel.CategoryId = model.CategoryId; viewModel.KeywordsId = model.KeywordsId; viewModel.PublishPlacesId = model.PublishPlacesId; viewModel.PhotoUrl = model.PhotoUrl; viewModel.PhotoId = model.PhotoId; viewModel.AllCategories = _queryDispatcher.Dispatch <List <Category> >(new GetCategoriesQuery()); viewModel.AllKeywords = _queryDispatcher.Dispatch <List <Keyword> >(new GetKeywordsQuery()); viewModel.AllPublishPlaces = _queryDispatcher.Dispatch <List <PublishPlace> >(new GetPlacesQuery()); viewModel.AllPhotos = _queryDispatcher.Dispatch <List <DtoPhotoList> >(new GetPhotosQuery()); return(View(viewModel)); } else { return(RedirectToAction("AccessDenied", "Account")); } }
public async Task <IActionResult> Update(EntityDTO input) { var content = await _contentService.GetContent(input); UpdateContentViewModel data = new UpdateContentViewModel() { Id = input.Id, Name = content.Name, Description = content.Description, Title = content.Title, IsHomePage = content.IsHomePage, IsCampaign = content.IsCampaign, Text = content.Text, }; return(View(data)); }
public async Task <IActionResult> Update(UpdateContentViewModel input) { try { string mainImageUrl = await _blobManager.UploadImageAsBlob(input.MainImage); string slideImageUrl = await _blobManager.UploadImageAsBlob(input.SlideImage); string videoUrl = await _blobManager.UploadImageAsBlob(input.Video); string audioUrl = await _blobManager.UploadImageAsBlob(input.Audio); UpdateContentDTO data = new UpdateContentDTO() { Id = input.Id, Name = input.Name, Description = input.Description, Title = input.Title, MainImageURL = mainImageUrl, SlideImageURL = slideImageUrl, VideoURL = videoUrl, AudioURL = audioUrl, IsHomePage = input.IsHomePage, IsCampaign = input.IsCampaign, Text = input.Text, CreatedTime = DateTime.Now, LocationId = input.LocationId }; await _contentService.UpdateContent(data); return(RedirectToAction(nameof(Index))); } catch (Exception e) { throw e; } }
// -------------------- public async Task <string> UpdateContent(UpdateContentViewModel model) { return(await _updateRepository.UpdateContent(model)); }