Esempio n. 1
0
 public HttpResponseMessage CreateCategory(Category category)
 {
     try
     {
         _categoryService.CreateCategory(category);
         return Request.CreateResponse(HttpStatusCode.OK, category);
     }
     catch (BadParametersException e)
     {
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, e);
     }
 }
Esempio n. 2
0
 public void CreateCategory(Category task)
 {
     if (task.Text == String.Empty)
     {
         throw new BadParametersException("Missed a name");
     }
     using (var unitOfWork = _unitOfWorkFactory.NewUnitOfWork())
     {
         unitOfWork.GetRepository<Category>().AddItem(task);
         unitOfWork.Commit();
     }
 }