public void Save(int propertyId, CategoryDto categoryToSave) { var property = _propertyRepository.Get(propertyId); var category = new Category(categoryToSave.Name, property, categoryToSave.TransactionType); if (categoryToSave.Id != 0) _categoryRepository.Update(category, categoryToSave.Id); else _categoryRepository.Add(category); }
public ActionResult Save(CategoryDto categoryDto) { _categoryApp.Save(SeletedPropertyId, categoryDto); return RedirectToAction("Index"); }
public ActionResult SaveCategory(CategoryDto categoryDto) { var login = Request.Headers["login"]; var token = Request.Headers["token"]; var propertyId = Convert.ToInt32(Request.Headers["propertyId"]); if (!ValidatePost(login, token, propertyId)) return Json("usuário inválido", JsonRequestBehavior.AllowGet); var categoryApp = new CategoryApp(_categoryRepository, _propertyRepository, _transactionRepository); categoryApp.Save(propertyId, categoryDto); return Json("OK"); }