public async Task <IActionResult> Put(string moniker, [FromBody] DiscussionModel discussionModel) { try { var discussion = await _discussionDataService.ReadItemAsync(moniker); if (discussion == null) { return(NotFound()); } var newDisc = _mapper.Map <Discussion>(discussionModel); discussion.Title = newDisc.Title ?? discussion.Title; discussion.Description = newDisc.Description ?? discussion.Description; await _discussionDataService.UpdateItem(discussion); return(Ok(discussion)); } catch (Exception e) { ; } return(BadRequest()); }
public async Task <bool> UpdateData(DiscussionModel data) { _context.DiscussionData.Update(data); return(await _context.SaveChangesAsync() == 1); //throw new NotImplementedException(); }
public async Task <bool> AddDiscussion(DiscussionModel data) { _context.DiscussionData.Add(data); var res = await _context.SaveChangesAsync(); return(res == 1); }
public async Task <IActionResult> Add([FromBody] DiscussionModel model) { if (!ModelState.IsValid) { ModelState.AddModelError("Summary", "Failed adding discussion"); return(BadRequest(ModelState)); } var person = await _Repository.GetPersonForClaimsPrincipalAsync(this.User); var discussion = model.ToDiscussion(); discussion.CreatedByPersonId = person.PersonId; var addedDiscussion = await _Repository.AddDiscussionAsync(discussion); return(new OkObjectResult(addedDiscussion.ToDiscussionModel())); }
public async Task <IActionResult> AddDiscussion(DiscussionModel dummyData) { dummyData.Id = Guid.NewGuid(); dummyData.Movie_ID = movie_id; dummyData.Movie_name = moviename; var currentUser = await _usermanger.GetUserAsync(User); if (currentUser == null) { return(Challenge()); } dummyData.Poster_ID = currentUser.Id; dummyData.poster_name = currentUser.UserName; var res = await discussionDataService.AddDiscussion(dummyData); return(await DetailDiscussion(dummyData.Id.ToString())); }
public ActionResult Index() { QuestionwithCategoryandMaxEntryViewModel qcm = new QuestionwithCategoryandMaxEntryViewModel(); var dcCat = _applicationDbContext.DiscussionCategories.OrderBy(n => n.Name).ToList(); var dcList = new List <DiscussionModel>(); foreach (var item in dcCat) { var questionsByCatId = _applicationDbContext.Questions.Where(id => id.DiscussionCategoryId == item.DiscussionCategoryId).ToList(); DiscussionModel dcModel = new DiscussionModel(); dcModel.Description = item.Description; dcModel.DiscussionName = item.Name; dcModel.DiscussionCategoryId = item.DiscussionCategoryId; dcModel.TotalEntryForCategory = questionsByCatId.Count(); dcList.Add(dcModel); } qcm.DiscussionModels = dcList; return(View(qcm)); }
public async Task <IActionResult> Post([FromBody] DiscussionModel discussionModel) { try { var discussion = _mapper.Map <Discussion>(discussionModel); await _discussionDataService.CreateItemAsync(discussion); //Create a new dynamic url for the new resource added. var newUri = Url.Link("GetUnicDiscussion", new { moniker = discussion.Id }); discussionModel.ID = discussion.Moniker; return(Created(newUri, discussionModel)); } catch (Exception e) { ; } return(BadRequest()); }
public async Task <bool> DeleteData(DiscussionModel data) { _context.DiscussionData.Remove(data); return(await _context.SaveChangesAsync() == 1); }
public async Task <IActionResult> DetailDiscussion(string idd) { DiscussionModel discussionModel = await discussionDataService.GetDataByidAsync(idd); return(View("DetailDiscussion", discussionModel)); }