示例#1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Contact.UpdatedAt = System.DateTime.Now;

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContactExists(Contact.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./MemberIndex"));
        }
示例#2
0
        public async Task <IActionResult> OnPostAsync(long?id)
        {
            var member = await _context.PremiseContacts.FindAsync(id);

            if (member != null)
            {
                member.IsDeleted = true;

                _context.Attach(member).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }



            return(RedirectToPage("./ProfileIndex"));
        }
示例#3
0
        public async Task <IActionResult> OnPostAsync()
        {
            var user = await GetUser();

            foreach (var item in MailSubscriptions)
            {
                if (item.MailSubscriptionId == 0)
                {
                    var ms = new MailSubscription
                    {
                        Email      = user.UserName,
                        MailTypeId = item.MailTypeId,
                        Name       = ""
                    };

                    await _context.AddAsync(ms);

                    await _context.SaveChangesAsync();
                }
                else
                {
                    var ms = new MailSubscription
                    {
                        Id          = item.MailSubscriptionId,
                        Email       = user.UserName,
                        MailTypeId  = item.MailTypeId,
                        Name        = "",
                        IsScription = item.IsScription
                    };

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

                    await _context.SaveChangesAsync();
                }
            }
            ;

            return(RedirectToPage());
        }