コード例 #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToPage("Create"));
            }

            ContactTypeToListRelationship.User = await _context.AspNetUsers.FirstAsync(
                u => u.UserName == HttpContext.User.Identity.Name
                );

            _context.ContactTypeToListRelationship.Add(ContactTypeToListRelationship);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
コード例 #2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ContactTypeToListRelationship =
                await _context.ContactTypeToListRelationship
                .Where(c => c.User.UserName == HttpContext.User.Identity.Name)
                .FirstOrDefaultAsync(c => c.ID == (int)id);

            if (ContactTypeToListRelationship != null)
            {
                _context.ContactTypeToListRelationship.Remove(ContactTypeToListRelationship);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
コード例 #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            ContactTypeToListRelationship.ID = (int)id;

            _context.Attach(ContactTypeToListRelationship).State = EntityState.Modified;



            ContactTypeToListRelationship.User = await _context.AspNetUsers.FirstAsync(
                u => u.UserName == HttpContext.User.Identity.Name
                );

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContactTypeToListRelationshipExists(ContactTypeToListRelationship.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
コード例 #4
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DealStageFilter = await _context.DealStageFilters
                              .Include(d => d.User)
                              .Where(d => d.User.UserName == HttpContext.User.Identity.Name)
                              .FirstOrDefaultAsync(m => m.ID == id);

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

            _context.DealStageFilters.Remove(DealStageFilter);
            await _context.SaveChangesAsync();

            return(RedirectToPage("Index"));
        }
コード例 #5
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            dynamic requestDealStageFilter =
                JsonConvert.DeserializeObject <dynamic>(Request.Form["DealStages"]);

            DealStageFilter.StageName =
                requestDealStageFilter.pipelineLabel + " - " + requestDealStageFilter.label;

            DealStageFilter.StageID = requestDealStageFilter.stageId;

            DealStageFilter.User = await _context.AspNetUsers
                                   .FirstAsync(u => u.UserName == HttpContext.User.Identity.Name);

            _context.DealStageFilters.Add(DealStageFilter);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }