示例#1
0
        public async Task <ActionResult <Customer> > PostCustomer(Customer customer)
        {
            await _context.Add(customer);


            return(CreatedAtAction("GetCustomer", new { id = customer.Id }, customer));
        }
示例#2
0
 public async Task <IActionResult> Create([Bind("CustomerId,FirstName,LastName,Address,Phone,City,State,Zipcode")] Customers customers)
 {
     if (ModelState.IsValid)
     {
         _customerRepo.Add(customers);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(customers));
 }
示例#3
0
        public override async Task Execute(SagaContext <string> context)
        {
            var trialPlan = await planRepo.FindDefault();

            var customer = await customerGateway.CreateTrialCustomer(context.Data.User, trialPlan);

            await customerRepo.Add(customer);

            context.Data.Plan = trialPlan;
        }
示例#4
0
        public async Task <IActionResult> PostCustomer([FromBody] Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _customerRepository.Add(customer);

            return(CreatedAtAction("GetCustomer", new { id = customer.CustomerId }, customer));
        }
        public IActionResult Create([FromBody] CustomerItem item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _custRepo.Add(item);

            return(CreatedAtRoute("GetCust", new { id = item.CustomerId }, item));
        }
示例#6
0
        public IActionResult Create([Bind("SSN, FirstName, LastName")] Customer customer)
        {
            foreach (var item in _customerRepo.AllCustomers())
            {
                if (item.SSN == customer.SSN)
                {
                    ViewBag.error = $"Kunden {customer.SSN} finns redan i databasen";
                    return(View("~/Views/Customer/CreateNewCustomer.cshtml"));
                }
            }
            if (ModelState.IsValid)
            {
                _customerRepo.Add(customer);
                ViewBag.ok = $"Kunden {customer.FirstName} är tillagd";
                return(View("~/Views/Home/Index.cshtml"));
            }

            return(View("~/Views/Customer/CreateNewCustomer.cshtml"));
        }