示例#1
0
        public CheckInOut(Boolean checkin, string barCode)
        {
            InitializeComponent();

            BindingContext = new CheckInOutViewModel(checkin, barCode)
            {
                Navigation = this.Navigation
            };
        }
示例#2
0
        public async Task <Result> Checkout(CheckInOutViewModel CheckInOutVM)
        {
            var CheckInOut = _context.CheckInOut.Where(c => c.UserId == CheckInOutVM.UserId && c.ShopId == CheckInOutVM.ShopId && c.CheckOutDate == null).FirstOrDefault();
            var userName   = _context.Users.Where(u => u.Id == CheckInOutVM.UserId).Select(u => u.FullName).FirstOrDefault();
            var shopName   = _context.Shop.Where(u => u.Id == CheckInOutVM.ShopId).Select(u => u.Name).FirstOrDefault();

            CheckInOut.CheckOutDate     = DateTime.Now;
            CheckInOut.ModificationDate = DateTime.Now;
            CheckInOut.UpdatedBy        = "Test";

            _context.SaveChanges();


            #region SendNotification For checkedIn User
            //send notifications
            var title = Resources.CheckOutTitle;
            var body  = Resources.Checkedout + " " + shopName + " " + Resources.Successfully;

            PayLoadViewModel payLoadData = new PayLoadViewModel
            {
                InfectedUserName = "******",
                Title            = title,
                Body             = body
            };

            var TokensList = GetUserToken(CheckInOut.UserId);

            FirebaseHelper.SendNotification(TokensList, title, body, payLoadData);

            #endregion


            #region SendNotification For Shop
            //send notifications
            var titleShop = Resources.CheckOutTitle;
            var bodyShop  = userName + " " + Resources.CheckOutStore;

            PayLoadViewModel payLoadDataShop = new PayLoadViewModel
            {
                InfectedUserName = "******",
                Title            = titleShop,
                Body             = bodyShop
            };

            var TokensListShop = GetShopToken(CheckInOut.ShopId);

            FirebaseHelper.SendNotification(TokensListShop, titleShop, bodyShop, payLoadDataShop);

            #endregion

            return(new Result()
            {
                IsSuccess = true,
                Errors = new List <string>()
            });
        }
示例#3
0
        public async Task <ActionResult <Result> > Checkout(CheckInOutViewModel CheckInOutVM)
        {
            try
            {
                var Result = await _ShopManager.Checkout(CheckInOutVM);

                return(Result);
            }
            catch (Exception ex)
            {
                _exceptionManager.SaveLog(Request.Path, CheckInOutVM, ex, null);
                return(new Result()
                {
                    IsSuccess = false,
                    Errors = new List <string> {
                        Resources.ExceptionMessage
                    }
                });
            }
        }
示例#4
0
        protected override async Task Initialize()
        {
            try
            {
                var currentID = await SettingsDataService.GetCurrentMobileConfigurationID();

                var configurations = await _mobileAppConfigDataService.GetMobileAppConfigs();

                var mcSelectViewModels = VisualBrowserViewModelBuilder.CreateMobileConfigurationsSelectionViewModel(configurations, SettingsDataService, currentID, () => { MobileConfigurations.ForEach(mc => mc.IsSelected = false); }, () => { IsSelectConfigurationPopupOpen = false; });
                MobileConfigurations = new ObservableCollection <MobileConfigurationsSelectionViewModel>(mcSelectViewModels);

                SetLogInOutStatus();

                IsInternalModeEnableChecked = IsInternalModeEnable;

                RefreshCommands();
                SetCheckInOutIcon(_presentationDataService);
                CheckInOutViewModel = new CheckInOutViewModel(_contactsService, _presentationDataService, SettingsDataService);
            }
            catch
            {
                //todo: log error
            }
        }
示例#5
0
        public async Task <Result> CheckIn(CheckInOutViewModel CheckInOutVM)
        {
            var LatestCheckOut = _context.CheckInOut.Where(c => c.ShopId == CheckInOutVM.ShopId && c.UserId == CheckInOutVM.UserId).OrderByDescending(c => c.Id).Select(c => c.CheckOutDate).FirstOrDefault();
            var LatestCheckIn  = _context.CheckInOut.Where(c => c.ShopId == CheckInOutVM.ShopId && c.UserId == CheckInOutVM.UserId).OrderByDescending(c => c.Id).Select(c => c.CheckInDate).FirstOrDefault();
            var userName       = _context.Users.Where(u => u.Id == CheckInOutVM.UserId).Select(u => u.FullName).FirstOrDefault();
            var shopName       = _context.Shop.Where(u => u.Id == CheckInOutVM.ShopId).Select(u => u.Name).FirstOrDefault();

            if (LatestCheckIn != null && LatestCheckOut == null)
            {
                return(new Result()
                {
                    IsSuccess = false,
                    Errors = new List <string> {
                        Resources.PleaseCheckOutOfShopToCheckInAgain
                    }
                });
            }
            else
            {
                CheckInOut CheckInOut = new CheckInOut();
                CheckInOut.UserId       = CheckInOutVM.UserId;
                CheckInOut.ShopId       = CheckInOutVM.ShopId;
                CheckInOut.CheckInDate  = DateTime.Now;
                CheckInOut.CreationDate = DateTime.Now;
                CheckInOut.CreatedBy    = "Test";
                CheckInOut.IsActive     = true;
                _context.CheckInOut.Add(CheckInOut);
                _context.SaveChanges();


                #region SendNotification For checkedIn User
                //send notifications
                var title = Resources.CheckInTitle;
                var body  = Resources.CheckedIn + " " + shopName + " " + Resources.Successfully;

                PayLoadViewModel payLoadData = new PayLoadViewModel
                {
                    InfectedUserName = "******",
                    Title            = title,
                    Body             = body
                };

                var TokensList = GetUserToken(CheckInOut.UserId);

                FirebaseHelper.SendNotification(TokensList, title, body, payLoadData);

                #endregion


                #region SendNotification For Shop
                //send notifications
                var titleShop = Resources.CheckInTitle;
                var bodyShop  = userName + " " + Resources.CheckInStore;

                PayLoadViewModel payLoadDataShop = new PayLoadViewModel
                {
                    InfectedUserName = "******",
                    Title            = titleShop,
                    Body             = bodyShop
                };

                var TokensListShop = GetShopToken(CheckInOut.ShopId);

                FirebaseHelper.SendNotification(TokensListShop, titleShop, bodyShop, payLoadDataShop);

                #endregion



                return(new Result()
                {
                    IsSuccess = true,
                    Errors = new List <string>()
                });
            }
        }