Ejemplo n.º 1
0
 public static object CreateWithNullTags()
 {
     var result = new AddConceptViewModel
     {
         AuthorId = 44,
         Description = "test-add-concept-view-model-descriptions",
         Title = "test-add-concept-view-model-title",
         Tags = null,
     };
     return result;
 }
Ejemplo n.º 2
0
        public static AddConceptViewModel CreateValidWithoutTags()
        {
            var result = new AddConceptViewModel
                             {
                                 AuthorId = 44,
                                 Description = "test-add-concept-view-model-descriptions",
                                 Title = "test-add-concept-view-model-title",
                                 Tags = null
                             };

            return result;
        }
Ejemplo n.º 3
0
        public static AddConceptViewModel CreateWithTags()
        {
            var result = new AddConceptViewModel
            {
                AuthorId = 44,
                Description = "test-add-concept-view-model-descriptions",
                Title = "test-add-concept-view-model-title",
                Tags = "tag;mark;concept"
            };

            return result;
        }
Ejemplo n.º 4
0
 public ActionResult Add(AddConceptViewModel model)
 {
     if (ModelState.IsValid)
     {
         var id = this.conceptLogic.Add(model);
         return this.RedirectToAction("Details", "Concepts", new { id = id });
     }
     else
     {
         return this.View("Add", model);
     }
 }
Ejemplo n.º 5
0
        public JsonResult<OperationResult<long>> Post(AddConceptViewModel model)
        {
            OperationResult<long> operationResult;
            if (ModelState.IsValid)
            {
                operationResult = this.conceptLogic.Add(model);
            }
            else
            {
                var errors =
                    this.ModelState.Values.SelectMany(x => x.Errors).Select(x => x).Select(x => x.ErrorMessage).ToList();
                operationResult = new OperationResult<long>(0, false, errors);

            }

            var result = new JsonResult<OperationResult<long>>(
                 operationResult,
                 new JsonSerializerSettings(),
                 Encoding.Default,
                 this);

            return result;
        }
Ejemplo n.º 6
0
 public OperationResult<AddConceptViewModel> GetAddConceptViewModel()
 {
     var result = new AddConceptViewModel { AuthorId = 1, };
     return new OperationResult<AddConceptViewModel>(result);
 }
Ejemplo n.º 7
0
 public OperationResult<long> Add(AddConceptViewModel model)
 {
     var concept = Mapper.Map<AddConcept>(model);
     var id = this.conceptsService.Add(concept);
     return new OperationResult<long>(id);
 }