예제 #1
0
        public void Update(Models.Agency entity)
        {
            var agencyInDatabase = db.Agencies.Find(entity.AgencyID);

            if (agencyInDatabase == null)
            {
                Add(entity);
            }
            else
            {
                db.Entry(agencyInDatabase).CurrentValues.SetValues(entity);
            }
        }
예제 #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Agency = await _context.Agency.FirstOrDefaultAsync(m => m.Id == id);

            if (Agency == null)
            {
                return(NotFound());
            }
            return(Page());
        }
예제 #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Agency = await _context.Agency.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
예제 #4
0
        public async Task ReplyWithSettingUserAgencyAsync(IBot bot, Update update, int agencyId)
        {
            UserChat userChat = update.ToUserchat();
            var      chatId   = update.GetChatId();
            int      msgId    = update.GetMessageId();

            await PersistNewUserAsync(chatId, userChat.UserId, agencyId);

            await bot.Client.DeleteMessageAsync(chatId, msgId);

            Models.Agency agency = await _dbContext.Agencies.SingleAsync(a => a.Id == agencyId);

            await bot.Client.SendTextMessageAsync(chatId,
                                                  string.Format("Great! Your agency is set to:\n*{0}*", agency.Title),
                                                  ParseMode.Markdown,
                                                  replyMarkup : new ReplyKeyboardRemove());
        }
예제 #5
0
 public void Add(Models.Agency entity)
 {
     db.Agencies.Add(entity);
 }