public IActionResult Add(AddRevenueViewModel addRevenueViewModel) { if (ModelState.IsValid) { RevenueCategory newRevenueCategory = context.RevenueCategories.Single(c => c.ID == addRevenueViewModel.RevenueCategoryID); // Add the new cheese to my existing cheeses Revenue newRevenue = new Revenue { Date = addRevenueViewModel.Date, Reference = addRevenueViewModel.Reference, Owner = addRevenueViewModel.Owner, Description = addRevenueViewModel.Description, Amount = addRevenueViewModel.Amount, RevenueCategory = newRevenueCategory }; context.Revenues.Add(newRevenue); context.SaveChanges(); return(Redirect("/Revenue")); } return(View(addRevenueViewModel)); }
public void Create(RevenueCategory revenueCategory) { if (revenueCategory == null) { return; } _fukiziPfmContext.RevenueCategories.Add(revenueCategory); _fukiziPfmContext.SaveChanges(); }
public void Update(RevenueCategory revenueCategory) { var dbCat = _fukiziPfmContext.RevenueCategories.FirstOrDefault(ec => ec.Id == revenueCategory.Id); if (dbCat != null) { dbCat.Name = revenueCategory.Name; } _fukiziPfmContext.SaveChanges(); }
public void Save(RevenueCategory revenueCategory) { if (revenueCategory.Id != 0) { Update(revenueCategory); } else { Create(revenueCategory); } }
public IActionResult Remove(int[] revenueCategoryIds) { foreach (int revenueCategoryId in revenueCategoryIds) { RevenueCategory theRevenueCategory = context.RevenueCategories.Single(c => c.ID == revenueCategoryId); context.RevenueCategories.Remove(theRevenueCategory); } context.SaveChanges(); return(Redirect("/RevenueCategory")); }
public IActionResult RevCategory(int id) { if (id == 0) { Redirect("/Load"); } RevenueCategory theCategory = context.RevenueCategories .Include(cat => cat.Loads) .Single(cat => cat.ID == id); ViewBag.Title = "Loads in Revenu Category" + theCategory.Name; return(View("Index", theCategory.Loads)); }
public IActionResult Add(AddRevenueCategoryViewModel addRevenueCategoryViewModel) { if (ModelState.IsValid) { RevenueCategory newRevenueCategory = new RevenueCategory { Name = addRevenueCategoryViewModel.Name, }; context.RevenueCategories.Add(newRevenueCategory); context.SaveChanges(); return(Redirect("/RevenueCategory")); } return(View(addRevenueCategoryViewModel)); }
public IActionResult Category(int id) { if (id == 0) { Redirect("/Category"); } RevenueCategory theCategory = context.RevenueCategories .Include(cat => cat.Revenues) .Single(cat => cat.ID == id); /* * IList<Cheese> theCheese = Context.Cheeses * .Include(c => c.Category) * .Single(c => c.CategoryID ==id) * .ToList();*/ ViewBag.Title = "cheeses in Category" + theCategory.Name; return(View("Index", theCategory.Revenues)); }