예제 #1
0
        // GET: Surveys/Details/5
        public async Task <IActionResult> Details()
        {
            SurveyItems si = new SurveyItems();

            var userId   = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var customer = _context.Customers
                           .Include(c => c.BillingAddress)
                           .Include(c => c.Payment)
                           .Include(c => c.ShippingAddress)
                           .Include(c => c.Survey)
                           .Where(m => m.IdentityUserId == userId).FirstOrDefault();

            var custSurvey = await _context.Surveys.FirstOrDefaultAsync(s => s.SurveyId == customer.SurveyId);

            si.Survey = custSurvey;

            var item = _context.Items.Where(h => h.StyleType == si.Survey.StyleType).Where(h => h.HomeType == si.Survey.HomeType).Where(h => h.LifeType == si.Survey.LifeType).FirstOrDefault();

            var custItems = _context.Items.SingleOrDefault(j => j.ItemId == item.ItemId);

            si.Item = custItems;

            if (custSurvey == null)
            {
                return(NotFound());
            }

            return(View("Details", si));
        }
예제 #2
0
        public async Task <IActionResult> Create(SurveyItems surveyItems, Survey survey)
        {
            var userId   = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var customer = _context.Customers
                           .Include(a => a.Survey)
                           .Include(a => a.BillingAddress)
                           .Include(s => s.ShippingAddress)
                           .Include(p => p.Payment)
                           .Where(c => c.IdentityUserId == userId)
                           .FirstOrDefault();


            if (ModelState.IsValid)
            {
                _context.Add(survey);
                await _context.SaveChangesAsync();

                return(View("Details", surveyItems));
            }
            return(View());
        }