Exemplo n.º 1
0
        public async Task <ActionResult> Create(CreateProvVM model)
        {
            if (ModelState.IsValid)
            {
                Providers newprov = new Providers()
                {
                    ProvName    = model.ProvName,
                    Notes       = model.Notes,
                    DateCreated = DateTimeOffset.Now
                };

                //try
                //{
                //    await _providersService.Create(newprov);

                //    TempData.Add("SuccessMsg", "The new provider was created successfully!");
                //}
                //catch (Exception ex)
                //{
                //    // Add message to the user
                //    Console.WriteLine("An error has occurred. Message: " + ex.ToString());
                //    throw;
                //}
                await _providersService.Create(newprov);

                return(RedirectToAction("Index"));
                //db.Products.Add(products);
                //await db.SaveChangesAsync();
                //return RedirectToAction("Index");
            }

            //ViewBag.ProvId = new SelectList(db.Providers, "ProvId", "ProvName", products.ProvId);
            return(View(model));
        }
Exemplo n.º 2
0
        // GET: Providers/Create
        public ActionResult Create()
        {
            CreateProvVM model = new CreateProvVM();

            //ViewBag.ProvId = new SelectList(db.Providers, "ProvId", "ProvName");
            return(View(model));
        }