예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CustomerName,Location")] Customer.Models.Customer customer)
        {
            if (id != customer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <Subscriptions> CreateSubscriptionAsync(Customer.Models.Customer customer)
        {
            if (customer == null)
            {
                return(null);
            }

            var subscription = new Subscriptions
            {
                SubscriptionId   = Guid.NewGuid(),
                CustomerId       = customer.CustomerId,
                TouchPointId     = customer.LastModifiedTouchpointId,
                Subscribe        = true,
                LastModifiedDate = customer.LastModifiedDate,
            };

            if (!customer.LastModifiedDate.HasValue)
            {
                subscription.LastModifiedDate = DateTime.Now;
            }

            var documentDbProvider = new DocumentDBProvider();

            var response = await documentDbProvider.CreateSubscriptionsAsync(subscription);

            return(response.StatusCode == HttpStatusCode.Created ? (dynamic)response.Resource : (Guid?)null);
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("Id,CustomerName,Location")] Customer.Models.Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }