private Status BuildPost(AddStatusModel model, ApplicationUser user, StatusCategoryListingModel dol) { var category = _statuscategoryImplementation.GetById(dol.StatusCategoryId); return(new Status { StatusTitle = model.StatusTitle, StatusCreated = DateTime.Now, StatusCategory = category, User = user, }); }
public IActionResult Create() { var StatusCategoryListingModel = _statuscategoryImplementation.GetAll().Select(q => new StatusCategoryListingModel { StatusCategoryId = q.StatusCategoryId, StatusCategoryTitle = q.StatusCategoryTitle, }); var model = new AddStatusModel { StatusCategory = StatusCategoryListingModel, AuthorName = User.Identity.Name, }; return(View(model)); }
public async Task <IActionResult> AddStatus(AddStatusModel model, StatusCategoryListingModel dol) { var userId = _userManager.GetUserId(User); var user = _userManager.FindByIdAsync(userId).Result; var status = BuildPost(model, user, dol); string[] censoredWords = System.IO.File.ReadAllLines(@"CensoredWords.txt"); Censor censor = new Censor(censoredWords); status.StatusTitle = censor.CensorText(status.StatusTitle); await _statusImplementation.AddStatus(status); await _applicationUserImplementation.UpdateUserRating(userId, typeof(Status)); return(RedirectToAction("Index", "Status", new { id = status.StatusId })); }