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); } }
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()); }
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")); }
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()); }
public void Add(Models.Agency entity) { db.Agencies.Add(entity); }