Example #1
0
 /**
 Creates a ChecklistModel object from a ChecklistViewModel. The multi-line text in
 viewModel.Items will be converted to a list of ChecklistItems in the resulting
 ChecklistModel's Items.
 **/
 public static ChecklistModel FromViewModel(ChecklistViewModel viewModel)
 {
     return new ChecklistModel()
     {
         Title = Tools.Web.FormInput.PrepareText(viewModel.Title, TitleMaxLength),
         Description = Tools.Web.FormInput.PrepareText(viewModel.Description, DescriptionMaxLength),
         Items = ChecklistItem.FromText(viewModel.Items)
     };
 }
 public IActionResult New(ChecklistViewModel viewModel)
 {
     var model = ChecklistModel.FromViewModel(viewModel);
     if (!mSpamDetectionService.IsSpamDescription(model.Description) && string.IsNullOrEmpty(viewModel.LeaveMeAlone))
     {
         // No Spam
         mChecklistRepository.SaveChecklistModel(model);
         return Redirect($"/c/{model.Id}");
     }
     else
     {
         // This is SPAM! Don't save the result and redirect
         // to some random result so that the spam-poster thinks
         // it was successful.
         return Redirect($"/c/UFlFEI2RY0CbyPhPvmoqAQ");
     }
 }