Ejemplo n.º 1
0
        public async Task <IActionResult> ShopServices(ServicesModel servicesModel)
        {
            if (ModelState.IsValid)
            {
                ShopServicesDb services = new ShopServicesDb
                {
                    ServiceName        = servicesModel.ServiceName,
                    UserId             = int.Parse(Request.Cookies["UserID"]),
                    ServiceCost        = servicesModel.ServiceCost,
                    ServiceDescription = servicesModel.ServiceDescription,
                };

                bool result = await _repo.CreateShopServices(services);

                if (result)
                {
                    ViewBag.ServiceSuccess = $"A new Service Have been Added {services.ServiceName}";

                    //  return RedirectToAction("ShopServices", "Account");
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Couldn't Add Shop Services. Try Again With Cookies Enabled");
                }
            }
            return(View(servicesModel));
        }
Ejemplo n.º 2
0
        public async Task <bool> CreateShopServices(ShopServicesDb shopServices)
        {
            await context.AddAsync(shopServices);

            await context.SaveChangesAsync();

            return(await Task.FromResult(true));
        }