コード例 #1
0
 public static void InitializeContext(string appPath, string accessToken)
 {
     CaffeDbContext context = new CaffeDbContext(new Uri(appPath));
     context.SendingRequest += new EventHandler<SendingRequestEventArgs>(OnSendingRequest);
     context.MergeOption = System.Data.Services.Client.MergeOption.OverwriteChanges;
     _instance = context;
 }
コード例 #2
0
 public ManagerMainPageModel()
 {
     _context = CaffeDataContext.Instance;
     StatsPeriod = 0;
     Cashiers = new List<Cashier>();
     CashierStats = new List<CashierStatsModel>();
 }
コード例 #3
0
        public ManagerMainPage(Manager manager)
        {
            InitializeComponent();

            _context = CaffeDataContext.Instance;

            Model = new ManagerMainPageModel()
            {
                Name = manager.Name,
            };

            DataContext = Model;

            Model.UpdateCashiersList();
        }
コード例 #4
0
        public ManagerMainPage(CafeManagerLib.SharedModels.UserClientModel userModel)
        {
            InitializeComponent();

            _context = CaffeDataContext.Instance;

            Model = new ManagerMainPageModel()
            {
                Name = userModel.Name,
            };

            DataContext = Model;

            Model.UpdateCashiersList();
        }
コード例 #5
0
        public SuperuserMainPageViewModel(String superuserName)
        {
            _context = CaffeDataContext.Instance;
            var superuser = _context.Superusers.Expand(m => m.Managers).Where(s => s.Login == superuserName).FirstOrDefault();

            if (superuser != null)
            {
                Model = superuser;
            }
            else
            {
                throw new KeyNotFoundException();
            }

            _addManagerCommand = new AsyncCommand(async () => {
                AddManager();
            });
        }
コード例 #6
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {

            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
            User user;

            using (CaffeDbContext _db = new CaffeDbContext())
            {
                user = _db.GetUserByName(context.UserName);

                if (user == null || context.Password != user.Password)
                {
                    context.SetError("invalid_grant", "The user name or password is incorrect.");
                    return;
                }
            }

            var identity = new ClaimsIdentity(context.Options.AuthenticationType);
            identity.AddClaim(new Claim(ClaimTypes.Name, user.Login));
            identity.AddClaim(new Claim(ClaimTypes.Role, user.Role.ToString()));

            context.Validated(identity);
        }
コード例 #7
0
 public CashierPageModel()
 {
     _context = CaffeDataContext.Instance;
     Menu = _context.MenuItems.ToList();
     CurrentOrder = new List<OrderItem>();
 }