public ActionResult CreateCategory(SingleCategoryViewModel viewModel)
 {
     using (var svc = new TransactionDescriptionServiceClient())
     {
         var item = new CategoryModel
         {
             Name = viewModel.Name,
             Description = viewModel.Category
         };
         svc.AddTransactionCategory(item);
         var model = GetAllCategories(svc);
         return View("Index", model);
     }
 }
        public bool AddTransactionCategory(CategoryModel model)
        {
            try
            {
                using (var context = new SpendingReportEntities())
                {
                    TransactionCategory category = null;
                    var name = new CategoryName()
                    {
                        Description = model.Description
                    };
                    context.CategoryNames.Add(name);
                    if (model.Id != 0)
                    {
                        category = context.TransactionCategories.FirstOrDefault(i => i.Id == model.Id);
                    }
                    if (category == null)
                    {
                        category = context.TransactionCategories.FirstOrDefault(i => i.Name == model.Name) ??
                                      CreateTransactionCategory(context);
                    }
                    category.Name = model.Name;

                    category.CategoryNames.Add(name);
                    context.SaveChanges();

                    //todo: async
                    UpdateCategories(model.Description, category.Id);
                }

                return true;
            }
            catch (Exception ex)
            {
                throw new Exception("Error occured in add transaction description!", ex);
            }
        }