Exemplo n.º 1
0
        public HttpResponseMessage Get()
        {
            var category = CategoryApplication.Get();
            var dto      = category.Select(p => new CategoryDTO(p));

            return(Request.CreateResponse(HttpStatusCode.OK, dto));
        }
Exemplo n.º 2
0
 public void Convert(PostDTO source, Post target)
 {
     target.Title           = source.Title;
     target.Text            = source.Text;
     target.PublicationDate = source.PublicationDate;
     target.Category        = CategoryApplication.Get(source.Category);
     target.Author          = UserApplication.Get(source.Author);
     target.Slug            = source.Slug;
 }
Exemplo n.º 3
0
        public ActionResult Edit(Guid id)
        {
            var vm = _categoryApplication.Get(id);

            if (vm != null)
            {
                return(View("Edit", vm));
            }
            else
            {
                this.AddToastMessage("", "Category not found.", ToastType.Info);
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 4
0
        public HttpResponseMessage Put(Guid id, [FromBody] CategoryDTO categoryDTO)
        {
            var category = CategoryApplication.Get(id);

            if (category == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, new Note("Categoria não encontrado", Note.NoteType.Success)));
            }

            var converter = new CategoryConverter();

            converter.Convert(categoryDTO, category);

            try
            {
                CategoryApplication.Save(category);
                return(Request.CreateResponse(HttpStatusCode.OK, new Note("Categoria criado com sucesso", Note.NoteType.Success)));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new Note("Não foi possível salvar a categoria", ex.Message, Note.NoteType.Error)));
            }
        }
Exemplo n.º 5
0
        public HttpResponseMessage Get(string title)
        {
            var category = CategoryApplication.Get(title);

            return(Request.CreateResponse(HttpStatusCode.OK, category));
        }
Exemplo n.º 6
0
        public HttpResponseMessage Get(Guid id)
        {
            var category = CategoryApplication.Get(id);

            return(Request.CreateResponse(HttpStatusCode.OK, category));
        }