public HttpResponseMessage Get() { var category = CategoryApplication.Get(); var dto = category.Select(p => new CategoryDTO(p)); return(Request.CreateResponse(HttpStatusCode.OK, dto)); }
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; }
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")); } }
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))); } }
public HttpResponseMessage Get(string title) { var category = CategoryApplication.Get(title); return(Request.CreateResponse(HttpStatusCode.OK, category)); }
public HttpResponseMessage Get(Guid id) { var category = CategoryApplication.Get(id); return(Request.CreateResponse(HttpStatusCode.OK, category)); }