Exemplo n.º 1
0
 public ActionResult Create(VenueServices vs, string PostMethod)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var viewModel = new VenueServiceViewModel
             {
                 VS            = vs,
                 Venues        = _context.venues.ToList(),
                 SubCategories = _context.subCategories.ToList()
             };
         }
         vs.ApplicationUserCreatedById     = "4af95f1c-0f73-4df9-bb6d-166a07b6e5f4";
         vs.ApplicationUserCreatedDate     = DateTime.Now;
         vs.ApplicationUserLastUpdatedById = vs.ApplicationUserCreatedById;
         vs.ApplicationUserLastUpdatedDate = DateTime.Now;
         // TODO: Add insert logic here
         _context.VenueServices.Add(vs);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 2
0
        public ActionResult Edit(int id, VenueServices vs)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var viewModel = new VenueServiceViewModel
                    {
                        VS            = vs,
                        Venues        = _context.venues.ToList(),
                        SubCategories = _context.subCategories.ToList()
                    };

                    //return View("CustomerForm", viewModel);
                }
                // TODO: Add update logic here
                var vsinDb = _context.VenueServices.Single(s => s.Id == vs.Id);
                vsinDb.SubCategoriesId      = vs.SubCategoriesId;
                vsinDb.VenuesId             = vs.VenuesId;
                vsinDb.ActualCostPrice      = vs.ActualCostPrice;
                vsinDb.DiscountedPercentage = vs.DiscountedPercentage;

                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View("Index"));
            }
        }
Exemplo n.º 3
0
 // GET: VenueServices/Create
 public ActionResult Create(VenueServices vs)
 {
     try
     {
         var viewModel = new VenueServiceViewModel
         {
             VS            = vs,
             Venues        = _context.venues.ToList(),
             SubCategories = _context.subCategories.ToList()
         };
         return(View("Create", viewModel));
     }
     catch (Exception ex)
     {
         return(View());
     }
 }
Exemplo n.º 4
0
        // GET: VenueServices/Edit/5
        public ActionResult Edit(int id)
        {
            var vs = _context.VenueServices.SingleOrDefault(c => c.Id == id);

            if (vs == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new VenueServiceViewModel
            {
                VS            = vs,
                Venues        = _context.venues.ToList(),
                SubCategories = _context.subCategories.ToList()
            };

            return(View(viewModel));
        }