public static void CallbackQuery(CallbackQueryEventArgs e, ITelegramBotClient bot) { string message = e.CallbackQuery.Data; var chatId = e.CallbackQuery.From.Id; int id = 0; int.TryParse(message.Substring(6), out id); AdminBot.adminLog(message); Participant participant; using (MobileContext db = new MobileContext()) { try { var booking = db.Bookings.Single(c => c.Id == id); var bookingsWeek = db.Bookings.Remove(booking); db.SaveChanges(); } catch (InvalidOperationException ex) { _ = bot.SendTextMessageAsync(chatId, "Бронь уже удалена").Result; return; } participant = db.Participants.Single(c => c.Alias == e.CallbackQuery.From.Username); } using (FileStream fs = FormSchedule.FormScheduleImage(participant)) { Message mes = bot.SendPhotoAsync(chatId: chatId, photo: new InputOnlineFile(fs, "schedule.png"), caption: "Бронь отменена.").Result; } }
// public bool validateleaves(string leavecode,string employeeid, datetime? fromdate, datetime? todate, out string errormsg) public bool validateleaves(string leavecode, string employeeid, decimal nofdays, out string errormsg) { try { errormsg = string.Empty; using (MobileContext context = new MobileContext()) { LeaveBalanceMaster leavebalancemaster = context.LeaveBalanceMaster .Where(l => l.LeaveCode == leavecode && l.EmpCode == employeeid).FirstOrDefault(); if (leavebalancemaster == null) { errormsg = "No leave balace configured from employee :" + employeeid; return(false); } // if (calculatenoofdays(fromdate, todate) > leavebalancemaster.balance) if (nofdays > Convert.ToDecimal(leavebalancemaster.Balance)) { errormsg = "desont have sucfficient days"; return(false); } return(true); } } catch (Exception ex) { throw ex; } }
public List <TourAdvance> TourApprovalProcess(string empcode, List <TourAdvance> toursList) { try { List <TourAdvance> processToures = new List <TourAdvance>(); using (MobileContext context = new MobileContext()) { foreach (var tours in toursList) { tours.ApprovedBy = empcode; context.TourAdvance.Update(tours); if (context.SaveChanges() > 0) { processToures.Add(tours); } } } return(processToures); } catch (Exception ex) { throw ex; } }
public static void Initialize(MobileContext context) { if (!context.Phones.Any()) { context.Phones.AddRange( new Phone { Name = "iPhone X", Company = "Apple", Price = 600 }, new Phone { Name = "Samsung Galaxy Edge", Company = "Samsung", Price = 550 }, new Phone { Name = "Pixel 3", Company = "Google", Price = 500 } ); context.SaveChanges(); } }
public Companies InsertCompanies(Companies companies, out string errorMessage) { try { errorMessage = string.Empty; using (MobileContext context = new MobileContext()) { var _code = context.Companies.Max(x => x.CompanyCode) ?? "0"; companies.CompanyCode = (Convert.ToInt32(_code) + 1).ToString(); companies.Active = "Y"; companies.AddDate = DateTime.Now; context.Add(companies); if (context.SaveChanges() > 0) { return(companies); } errorMessage = "failed to create client."; return(null); } } catch (Exception ex) { throw ex; } }
public static void PerformAnswer(Message message, ITelegramBotClient client, Participant participant) { var chatId = message.Chat.Id; var messageId = message.MessageId; //Здесь нужно получить список броней на алиасе запросившего за эту неделю, //После чего вывести инлайном клавиатуру со списком броней //поймать колбэк запроса DateTime now = DateTime.Today; int daynum = BookCommand.dayOfWeekInt(now); DateTime weekStart = now.AddDays(-daynum); DateTime weekEnd = weekStart.AddDays(+7); List <InlineKeyboardButton> buttons = new List <InlineKeyboardButton>(); using (MobileContext db = new MobileContext()) { var bookingsWeek = db.Bookings.Where(c => (c.Participant == participant) && (c.TimeStart > weekStart) && (c.TimeEnd < weekEnd)).OrderBy(c => c.TimeStart); foreach (var booking in bookingsWeek) { string caption = dayName(booking.TimeStart.DayOfWeek) + " " + booking.TimeStart.ToString("HH:mm") + " " + booking.TimeEnd.ToString("HH:mm"); buttons.Add(InlineKeyboardButton.WithCallbackData(caption, "cancel" + booking.Id)); } } InlineKeyboardMarkup reply = new InlineKeyboardMarkup(buttons); Message mes = client.SendTextMessageAsync(chatId, "Выберите отменяемую бронь", replyMarkup: reply).Result; }
public List <BiometricAttendance> GetAttendances(string empCode, DateTime?fromDate, DateTime?toDate) { try { List <BiometricAttendance> attendanceList = null; if (fromDate == null) { fromDate = DateTime.Now; } if (toDate == null) { toDate = DateTime.Now; } using (MobileContext context = new MobileContext()) { attendanceList = context.BiometricAttendance.AsEnumerable() .Where(b => b.EmpCode == empCode && Convert.ToDateTime(b.Date.Value.ToShortDateString()) <= Convert.ToDateTime(toDate.Value.ToShortDateString()) && Convert.ToDateTime(b.Date.Value.ToShortDateString()) <= Convert.ToDateTime(toDate.Value.ToShortDateString())) .OrderByDescending(x => x.Date) .ToList(); return(attendanceList); } } catch (Exception ex) { throw ex; } }
public static void Initialize(MobileContext context) { if (!context.Phones.Any()) { context.Phones.AddRange( new Phone { Name = "iPhone 6S", Company = "Apple", Price = 600 }, new Phone { Name = "Samsung Galaxy Edge", Company = "Samsung", Price = 550 }, new Phone { Name = "Lumia 950", Company = "Microsoft", Price = 500 } ); context.SaveChanges(); } }
private IContext MobileContext() { #if UNITY_IOS string idfa = Adjust.getIdfa() ?? "unknown_idfa"; #else string idfa = "unknown_idfa"; Adjust.getGoogleAdId((string googleAdId) => { idfa = googleAdId; }); #endif string[] versionInfo = deviceOS.Split(' '); string versionNumber = versionInfo.Last(); DebugLog($"Mobile context idfa: {idfa} -> version: {versionNumber}"); MobileContext context = new MobileContext() .SetOsType(deviceOS) //REQUIRED! .SetOsVersion(versionNumber) //REQUIRED! .SetDeviceManufacturer(deviceModel) //REQUIRED! .SetDeviceModel(deviceModel) //REQUIRED! .SetNetworkType(NetworkType.Mobile) #if UNITY_IOS .SetAppleIdfa(idfa) .SetAppleIdfv(Device.vendorIdentifier ?? "Editor") #else .SetAndroidIdfa(idfa) #endif .Build(); DebugLog($"MOBILE CONTEXT ({deviceOS}) : {context.GetJson()}"); return(context); }
public FilmsController(MobileContext context, IWebHostEnvironment hostEnvironment, ApplicationDbContext applicationDbContext, UserManager <User> userManager) { _context = context; webHostEnvironment = hostEnvironment; _applicationDbContext = applicationDbContext; _userManager = userManager; }
public List <LeaveApplDetails> RecomandationProcess(string employeecode, List <LeaveApplDetails> leaveappldetails) { try { List <LeaveApplDetails> prcoessemployess = new List <LeaveApplDetails>(); using (MobileContext context = new MobileContext()) { foreach (var lvaply in leaveappldetails) { try { if (lvaply.Status == STATUS.CANCEL.ToString()) { updateusedleaves(lvaply.EmpCode, lvaply.LeaveDays, context); } //lvaply.status = status.inprogress.tostring(); lvaply.RecommendedId = employeecode; lvaply.RecommendedName = getemployee(lvaply.RecommendedId)?.Name; context.LeaveApplDetails.Update(lvaply); if (context.SaveChanges() > 0) { prcoessemployess.Add(lvaply); } } catch { } } } return(prcoessemployess); } catch (Exception ex) { throw ex; } }
public static void Initializze(MobileContext context) { if (!context.Phones.Any()) { context.Phones.AddRange( new Phone { Name = "Honor 9 Lite", Company = "Huawei", Price = 15000 }, new Phone { Name = "Iphone 10", Company = "Apple", Price = 87000 }, new Phone { Name = "Zeon Empress", Company = "Vertex", Price = 3700 } ); context.SaveChanges(); } }
public Dictionary <Employees, BiometricAttendance> GetMyTeam(string employeeId) { try { Dictionary <Employees, BiometricAttendance> employeeAttenadance = new Dictionary <Employees, BiometricAttendance>(); using (MobileContext context = new MobileContext()) { var employees = context.Employees .Where(emp => emp.RecommendedBy == employeeId || emp.ApprovedBy == employeeId) .ToList(); foreach (var emp in employees) { var _attendance = context.BiometricAttendance.Where(x => x.EmpCode == emp.Code).OrderByDescending(x => x.Date).FirstOrDefault(); employeeAttenadance.Add(emp, _attendance); } } return(employeeAttenadance); } catch (Exception ex) { throw ex; } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MobileContext( serviceProvider.GetRequiredService < DbContextOptions <MobileContext> >())) { // Look for any movies. if (context.TaiKhoanAdmin.Any()) { return; // DB has been seeded } context.TaiKhoanAdmin.AddRange( new TaiKhoanAdmin { User = "******", Pass = MD5.GetMD5("SuperAdmin"), Name = "Phạm Toàn Trung", Email = "*****@*****.**", PhoneNumber = "0947902015", Role = "Super Admin", TrangThai = true } ); context.SaveChanges(); } }
public void updateusedleaves(string empcode, double?noofleaves, MobileContext context, bool isLeaveCanceled = false) { try { var leavebalancemaster = context.LeaveBalanceMaster.Where(x => x.UserId == empcode).FirstOrDefault(); if (isLeaveCanceled) { leavebalancemaster.Used -= noofleaves; leavebalancemaster.Balance += noofleaves; } else { leavebalancemaster.Used += noofleaves; leavebalancemaster.Balance -= noofleaves; } context.LeaveBalanceMaster.Update(leavebalancemaster); context.SaveChanges(); } catch (Exception ex) { throw; } }
public HomeController(ILogger <HomeController> logger, MobileContext context, IStringLocalizer <HomeController> localizer, ViewToStringRendererService viewToStringRendererService) { _logger = logger; _context = context; _localizer = localizer; _viewToStringRendererService = viewToStringRendererService; }
public HomeController(MobileContext context, IHostingEnvironment appEnvironment, IOptions <Restrictions> restrictions) { db = context; this.appEnvironment = appEnvironment; this.restrictions = restrictions.Value; }
public DonHangsController(MobileContext mb) { _mb = mb; DonHangVM = new DonHangViewChiTiet() { ChiTietDonHangs = _mb.ChiTietDonHang.ToList(), DonHangs = new Models.DonHang() }; }
static void Main(string[] args) { Console.WriteLine("Hello World!"); using (MobileContext context = new MobileContext()) { var phones = context.Phones.ToList(); System.Console.WriteLine(phones.Count); } }
private void OnTextChanged(object sender, TextChangedEventArgs e) { _company.Name = textBox.Text; using (MobileContext db = new MobileContext()) { db.Companies.Update(_company); db.SaveChanges(); } }
public CaNhanController(MobileContext db) { _db = db; GioHangVM = new GioHangViewModel() { DanhSachGH = new List <GioHang>(), DanhSachPost = new List <DanhSachPost>() }; }
public IMEI_DienThoaiController(MobileContext context) { _mb = context; CTHoaDonViewIMEIVM = new CTHoaDonViewIMEI() { iMEI_DienThoais = _mb.IMEI_DienThoai.ToList(), chiTietHoaDon = new Models.ChiTietHoaDon() }; }
public HoaDonsController(MobileContext mb) { _mb = mb; HoaDonVM = new HoaDonViewChiTietHoaDon() { ChiTietHoaDons = _mb.ChiTietHoaDon.ToList(), HoaDons = new Models.HoaDon() }; }
public MainWindow() { InitializeComponent(); _db = new MobileContext(); _db.Phones.Load(); phonesGrid.ItemsSource = _db.Phones.Local.ToBindingList(); Closing += MainWindow_Closing; }
public ModelDienThoaisController(MobileContext mb, IHostingEnvironment hostingEnvironment) { _mb = mb; _hostingEnvironment = hostingEnvironment; ModelDienThoaiVM = new ModelDienThoaiViewModel() { Hangs = _mb.Hang.ToList(), ModelDienThoais = new Models.ModelDienThoai() }; }
public AdminPhonesControllerTests() { var options = new DbContextOptionsBuilder <MobileContext>() .UseInMemoryDatabase(databaseName: "schooldb") .Options; _context = new MobileContext(options); _hostEnv = new Mock <IWebHostEnvironment>(); _controller = new PhonesController(_context, _hostEnv.Object); }
public MainWindow() { InitializeComponent(); db = new MobileContext(); db.Phones.Load(); // загружаем данные phonesGrid.ItemsSource = db.Phones.Local.ToBindingList(); // устанавливаем привязку к кэшу this.Closing += MainWindow_Closing; }
//IUnityContainer container = new UnityContainer(); public PhoneView() { InitializeComponent(); db = new MobileContext(); db.Phones.Load(); phonesGrid.ItemsSource = db.Phones.Local.ToBindingList(); //this.Closing += MainWindow_Closing; }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { InitializeComponent(); Suspending += OnSuspending; using (var db = new MobileContext()) { db.Database.Migrate(); } }
public DienThoaisController(MobileContext mb, IHostingEnvironment hostingEnvironment) { _mb = mb; _hostingEnvironment = hostingEnvironment; DienThoaiVM = new DienThoaisViewModel() { ModelDienThoais = _mb.ModelDienThoai.ToList(), DienThoais = new Models.DienThoai() }; }