Beispiel #1
0
        public IActionResult AddService(AddServiceModel model)
        {
            if (ModelState.IsValid)
            {
                _logic.GetLogic().AddNewService(new Service(model.AddName, model.AddCount, model.AddPrice));
            }

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public async Task <IActionResult> AddService([FromBody] AddServiceModel addServiceModel)
        {
            var user         = HttpContext.User;
            var contractorId = user.GetContractorId();
            var contractor   = await _dbContext.Contractors.FindAsync(contractorId);

            await _dbContext.Services.AddAsync(new Service(contractor, addServiceModel.Name, addServiceModel.Description));

            await _dbContext.SaveChangesAsync();

            //return Ok("Hello");
            return(BadRequest(2021));
        }
        public IActionResult AddService(AddServiceModel model)
        {
            if (ModelState.IsValid)
            {
                var subsribtion = new Subscription
                {
                    Name        = model.Name,
                    LastPayment = model.LastPayment,
                    Period      = model.Period,
                    Price       = model.Price
                };

                db.AddServiceToUser(subsribtion, User.Identity.Name);
                return(RedirectToAction("MyServices", "Home"));
            }
            return(View(model));
        }