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));
        }
Esempio n. 2
0
 public void Create(RevenueCategory revenueCategory)
 {
     if (revenueCategory == null)
     {
         return;
     }
     _fukiziPfmContext.RevenueCategories.Add(revenueCategory);
     _fukiziPfmContext.SaveChanges();
 }
Esempio n. 3
0
        public void Update(RevenueCategory revenueCategory)
        {
            var dbCat = _fukiziPfmContext.RevenueCategories.FirstOrDefault(ec => ec.Id == revenueCategory.Id);

            if (dbCat != null)
            {
                dbCat.Name = revenueCategory.Name;
            }
            _fukiziPfmContext.SaveChanges();
        }
Esempio n. 4
0
 public void Save(RevenueCategory revenueCategory)
 {
     if (revenueCategory.Id != 0)
     {
         Update(revenueCategory);
     }
     else
     {
         Create(revenueCategory);
     }
 }
Esempio n. 5
0
        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"));
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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));
        }