Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Date,RoomNumber,Adults,Kids")] CheckIns checkIns)
        {
            if (id != checkIns.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(checkIns);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CheckInsExists(checkIns.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(checkIns));
        }
Пример #2
0
        async Task ExecuteLoadCheckInsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                CheckIns.Clear();
                SPoints = 0;
                var checkIns = await ChDataStore.GetCheckInsAsync(true);

                foreach (var checkIn in checkIns)
                {
                    CheckIns.Add(checkIn);
                    SPoints += checkIn.SpValue;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("CheckInId,CheckInBidderNumber,GuestId,EventId")] CheckIns checkIns)
        {
            if (id != checkIns.CheckInId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(checkIns);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CheckInsExists(checkIns.CheckInId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"] = new SelectList(_context.Events, "EventId", "EventName", checkIns.EventId);
            ViewData["GuestId"] = new SelectList(_context.Guests, "GuestId", "GuestFullName", checkIns.GuestId);
            return(View(checkIns));
        }
Пример #4
0
        // Note that we ignore parameter 'count' because we only want to load 1 page at a time
        protected async override Task <IList <object> > LoadMoreItemsOverrideAsync(System.Threading.CancellationToken c, uint count)
        {
            int page = this.Count / APICommon.FETCH_SIZE;

            CheckInsListAPI data = await CheckIns.Get(page, APICommon.FETCH_SIZE, comment, codeBranchID);

            this.count = data.recordCount;

            return(data.data.ToArray());
        }
Пример #5
0
        public async Task <IActionResult> Create([Bind("ID,Date,RoomNumber,Adults,Kids")] CheckIns checkIns)
        {
            if (ModelState.IsValid)
            {
                _context.Add(checkIns);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(checkIns));
        }
        public bool CheckIn(CheckIns newCheckIns)
        {
            if (newCheckIns == null)
                throw new InvalidParameterException();

            newCheckIns.CheckInDate = DateTime.Now;

            var addNewChecInCommand = new AddNewCheckInCommand(dapperHub) {NewCheckIn = newCheckIns};

            addNewChecInCommand.Execute();

            return true;
        }
Пример #7
0
        public void SetNewAverageTime(double timeDifference)
        {
            int count = CheckIns.Count(x => x.Time != null);

            if (count == 0)
            {
                AverageTime = timeDifference;
            }
            else
            {
                AverageTime = (AverageTime * count + timeDifference) / (count + 1);
            }
        }
        public async Task <IActionResult> Create([Bind("CheckInId,CheckInBidderNumber,GuestId,EventId")] CheckIns checkIns)
        {
            if (ModelState.IsValid)
            {
                _context.Add(checkIns);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"] = new SelectList(_context.Events, "EventId", "EventName", checkIns.EventId);
            ViewData["GuestId"] = new SelectList(_context.Guests, "GuestId", "GuestFullName", checkIns.GuestId);
            return(View(checkIns));
        }
Пример #9
0
        public void CreateCheckIn(CheckInDTO checkInDTO)
        {
            string          userId = HttpContext.Current.User.Identity.GetUserId();
            ApplicationUser user   = db.Users.Find(userId);

            Barcodes barcode = db.Barcodes.Find(checkInDTO.BarcodeId);
            CheckIns ci      = new CheckIns();

            ci.CheckinTime = DateTime.Now;
            ci.CreatedDate = DateTime.Now;
            ci.CreatedBy   = user;
            ci.IsActive    = true;

            db.CheckIns.Add(ci);
            barcode.CheckIns = new List <CheckIns>();
            barcode.CheckIns.Add(ci);
            db.SaveChanges();
        }
Пример #10
0
        public async Task <IActionResult> Submit([Bind("roomno,NoAdults,noKids")] CheckIns checkIns)
        {
            if (ModelState.IsValid)
            {
                _context.Add(checkIns);
                await _context.SaveChangesAsync();

                var msg1 = new Message
                {
                    msg = "Success"
                };
                return(RedirectToAction(nameof(Index), routeValues: msg1));
            }
            var msg2 = new Message
            {
                msg = "Error"
            };

            return(RedirectToAction(nameof(Index), routeValues: msg2));
        }
Пример #11
0
        public Task <bool> ParseLine(string line)
        {
            var tokens = GetTokens(line);

            LogEvents tokenType;

            return(Task.Run(() =>
            {
                ProgressInt += progressInc;
                if (tokens.Any() && Enum.TryParse(tokens[0], out tokenType))
                {
                    switch (tokenType)
                    {
                    case LogEvents.PRODUCT:
                        return Products.TryAdd(ParseProduct(tokens));

                    case LogEvents.IN:
                        return CheckIns.TryAdd(ParseCheckIn(tokens));

                    case LogEvents.OUT:
                        return CheckOuts.TryAdd(ParseCheckOut(tokens));

                    case LogEvents.DENY:
                        return Denys.TryAdd(ParseDeny(tokens));

                    case LogEvents.SHUTDOWN:
                        return Shutdowns.TryAdd(ParseShutdown(tokens));

                    case LogEvents.END:
                        return ParseEnd(tokens);

                    default:
                        return false;
                    }
                }

                return false;
            }));
        }
Пример #12
0
 public CheckIn GetCheckedInResort()
 {
     return(CheckIns.Where(x => x.IsActive).SingleOrDefault());
 }
Пример #13
0
        void backgroundWorkerNewsFeed_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (e != null)
                {
                    if (e.Cancel)
                    {
                        return;
                    }
                }
                dynamic parameters = new ExpandoObject();

                if (!IsInitialFetch && LastUpdate != null)
                {
                    // danach kamen keine Updates mehr durch :(
                    //  parameters.since = GetUnixTimestamp(LastUpdate).ToString();
                }

                string[] feeds = { "home", "feed" };

                foreach (string feedName in feeds)
                {
                    dynamic result = facebookClient.Get("/me/" + feedName, parameters); // Home

                    if (result != null)
                    {
                        foreach (dynamic post in result.data)
                        {
                            if (e != null)
                            {
                                if (e.Cancel)
                                {
                                    return;
                                }
                            }
                            FacebookItem item = FacebookItem.ConvertResponseToItem(post, this);
                            if (item == null)
                            {
                                AppController.Current.Logger.writeToLogfile("Null item in facebook retrieval");
                                continue;
                            }

                            FacebookItem ExistingItem = null;
                            try
                            {
                                switch (item.MessageType)
                                {
                                case FacebookItem.MessageTypes.Link:
                                    if (Links.Where(oldItem => oldItem.fullId == item.fullId).Count() > 0)
                                    {
                                        ExistingItem = Links.Where(oldItem => oldItem.fullId == item.fullId).First();
                                    }

                                    break;

                                case FacebookItem.MessageTypes.Video:
                                    if (Videos.Where(oldItem => oldItem.fullId == item.fullId).Count() > 0)
                                    {
                                        ExistingItem = Videos.Where(oldItem => oldItem.fullId == item.fullId).First();
                                    }

                                    break;

                                case FacebookItem.MessageTypes.Photo:
                                    if (Photos.Where(oldItem => oldItem.fullId == item.fullId).Count() > 0)
                                    {
                                        ExistingItem = Photos.Where(oldItem => oldItem.fullId == item.fullId).First();
                                    }

                                    break;

                                case FacebookItem.MessageTypes.Note:
                                    if (Notes.Where(oldItem => oldItem.fullId == item.fullId).Count() > 0)
                                    {
                                        ExistingItem = Notes.Where(oldItem => oldItem.fullId == item.fullId).First();
                                    }

                                    break;

                                case FacebookItem.MessageTypes.Event:
                                    if (Events.Where(oldItem => oldItem.fullId == item.fullId).Count() > 0)
                                    {
                                        ExistingItem = Events.Where(oldItem => oldItem.fullId == item.fullId).First();
                                    }

                                    break;

                                case FacebookItem.MessageTypes.CheckIn:
                                    if (CheckIns.Where(oldItem => oldItem.fullId == item.fullId).Count() > 0)
                                    {
                                        ExistingItem = CheckIns.Where(oldItem => oldItem.fullId == item.fullId).First();
                                    }

                                    break;

                                default:
                                    if (StatusMessages.Where(oldItem => oldItem.fullId == item.fullId).Count() > 0)
                                    {
                                        ExistingItem = StatusMessages.Where(oldItem => oldItem.fullId == item.fullId).First();
                                    }

                                    break;
                                }
                            }
                            catch
                            {
                                ExistingItem = null;
                            }
                            if (ExistingItem == null)
                            {
                                try
                                {
                                    dynamic comments = facebookClient.Get("/" + item.fullId + "/comments", parameters);
                                    item.Comments.Clear();
                                    if (comments != null)
                                    {
                                        if (comments.data != null)
                                        {
                                            AppController.Current.Logger.writeToLogfile("Facebook item has comments/data");
                                            foreach (dynamic fbcomment in comments.data)
                                            {
                                                AppController.Current.Logger.writeToLogfile("Reading comment");
                                                FacebookComment comment = new FacebookComment(fbcomment);
                                                comment.Account = item.Account;
                                                if (comment.User.Id == this.Id.ToString())
                                                {
                                                    item.isCommented = true;
                                                }
                                                item.Comments.Add(comment);
                                            }
                                        }
                                    }
                                }
                                catch { }
                                item.ReceivingAccount = this;
                                backgroundWorkerNewsFeed.ReportProgress(100, item);
                                continue;
                            }
                            else
                            {
                                if (item.LikesCount != ExistingItem.LikesCount)
                                {
                                    item.HasUpdatedLikes = true;
                                }

                                List <FacebookComment> updatedComments = new List <FacebookComment>();
                                foreach (FacebookComment comment in item.Comments)
                                {
                                    if (e != null)
                                    {
                                        if (e.Cancel)
                                        {
                                            return;
                                        }
                                    }
                                    if (ExistingItem.Comments.Where(c => c.Text == comment.Text && c.User.Id == comment.User.Id).Count() == 0)
                                    {
                                        updatedComments.Add(comment);
                                    }
                                }

                                if (updatedComments.Count > 0)
                                {
                                    item.HasUpdatedComments = true;
                                    item.Comments.Clear();
                                    foreach (FacebookComment comment in updatedComments)
                                    {
                                        item.Comments.Add(comment);
                                    }
                                }
                                if (item.HasUpdatedComments || item.HasUpdatedLikes)
                                {
                                    item.ReceivingAccount = this;
                                    backgroundWorkerNewsFeed.ReportProgress(100, item);
                                }
                                else
                                {
                                    item = null;
                                }
                            }
                        }
                    }
                }
            }
            catch (FacebookOAuthException oauthExp)
            {
                AppController.Current.Logger.writeToLogfile(oauthExp);
            }
            catch (Exception exp)
            {
                AppController.Current.Logger.writeToLogfile(exp);;
            }
        }
Пример #14
0
        void backgroundWorkerNewsFeed_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            FacebookItem item = (FacebookItem)e.UserState;

            if (item == null)
            {
                return;
            }

            string notificationClassName = "Facebook " + FullName + " ";

            if (item.HasUpdatedLikes || item.HasUpdatedComments)
            {
                FacebookItem ExistingItem = null;
                try
                {
                    switch (item.MessageType)
                    {
                    case FacebookItem.MessageTypes.Link:
                        ExistingItem = Links.Where(oldItem => oldItem.fullId == item.fullId).First();

                        break;

                    case FacebookItem.MessageTypes.Video:
                        ExistingItem = Videos.Where(oldItem => oldItem.fullId == item.fullId).First();

                        break;

                    case FacebookItem.MessageTypes.Photo:
                        ExistingItem = Photos.Where(oldItem => oldItem.fullId == item.fullId).First();

                        break;

                    case FacebookItem.MessageTypes.Note:
                        ExistingItem = Notes.Where(oldItem => oldItem.fullId == item.fullId).First();

                        break;

                    case FacebookItem.MessageTypes.Event:
                        ExistingItem = Events.Where(oldItem => oldItem.fullId == item.fullId).First();

                        break;

                    case FacebookItem.MessageTypes.CheckIn:
                        ExistingItem = CheckIns.Where(oldItem => oldItem.fullId == item.fullId).First();

                        break;

                    default:
                        ExistingItem = StatusMessages.Where(oldItem => oldItem.fullId == item.fullId).First();

                        break;
                    }


                    if (item.HasUpdatedLikes)
                    {
                        string notificationText = "";
                        if (!string.IsNullOrWhiteSpace(item.Text))
                        {
                            notificationText += item.Text.Substring(0, Math.Min(20, item.Text.Length - 1)) + "... ";
                        }
                        else
                        {
                            notificationText += "Facebook item... ";
                        }
                        notificationText += "has new likes";
                        if (item.isLiked)
                        {
                            AppController.Current.sendNotification(notificationClassName + "Like", notificationText, "The item has " + (item.LikesCount - ExistingItem.LikesCount).ToString() + " new likes", item.User.Avatar, null);
                        }
                        else
                        {
                            AppController.Current.sendNotification(notificationClassName + "Like (on message you didn't comment or like yourself)", notificationText, "The item has " + (item.LikesCount - ExistingItem.LikesCount).ToString() + " new likes", item.User.Avatar, null);
                        }
                        ExistingItem.UpdatedAt  = item.UpdatedAt;
                        ExistingItem.LikesCount = item.LikesCount;
                    }
                    if (item.HasUpdatedComments)
                    {
                        foreach (FacebookComment newComment in item.Comments)
                        {
                            if (item.isCommented)
                            {
                                AppController.Current.sendNotification(notificationClassName + "Comment", "New comment on entry of " + ExistingItem.User.FullName, newComment.Text + "\r\nby " + newComment.User.FullName, newComment.User.Avatar, null);
                            }
                            else
                            {
                                AppController.Current.sendNotification(notificationClassName + "Comment (on message you didn't comment or like yourself)", "New comment on entry of " + ExistingItem.User.FullName, newComment.Text + "\r\nby " + newComment.User.FullName, newComment.User.Avatar, null);
                            }
                            ExistingItem.Comments.Add(newComment);
                            ExistingItem.UpdatedAt = item.UpdatedAt;
                        }
                    }
                }
                catch (Exception exp)
                {
                    AppController.Current.Logger.writeToLogfile(exp);
                }
            }
            else
            {
                switch (item.MessageType)
                {
                case FacebookItem.MessageTypes.Link:

                    Links.Add(item);
                    if (InitialUpdateDoneForLinks)
                    {
                        notificationClassName += "Link";
                    }

                    break;

                case FacebookItem.MessageTypes.Video:

                    Videos.Add(item);
                    if (InitialUpdateDoneForVideos)
                    {
                        notificationClassName += "Video";
                    }

                    break;

                case FacebookItem.MessageTypes.Photo:

                    Photos.Add(item);
                    if (InitialUpdateDoneForPhotos)
                    {
                        notificationClassName += "Photo";
                    }

                    break;

                case FacebookItem.MessageTypes.Note:

                    Notes.Add(item);
                    if (InitialUpdateDoneForNotes)
                    {
                        notificationClassName += "Note";
                    }

                    break;

                case FacebookItem.MessageTypes.Event:

                    Events.Add(item);
                    if (InitialUpdateDoneForEvents)
                    {
                        notificationClassName += "Event";
                    }

                    break;

                case FacebookItem.MessageTypes.CheckIn:

                    CheckIns.Add(item);
                    if (InitialUpdateDoneForCheckIns)
                    {
                        notificationClassName += "CheckIn";
                    }

                    break;

                default:

                    StatusMessages.Add(item);
                    if (InitialUpdateDoneForStatusMessages)
                    {
                        notificationClassName += "Status message";
                    }

                    break;
                }

                if (notificationClassName != "Facebook " + FullName + " ")
                {
                    AppController.Current.sendNotification(notificationClassName, item.User.FullName, item.Text, item.Avatar, item);
                }
            }
        }
        private static void SeedGuests(ApplicationDbContext db, ILogger log)
        {
            var b = db.Bookings.FirstOrDefault();

            if (b == null)
            {
                log.LogInformation("Seeding Booking entries");
                var bookings = new List <Bookings>();
                b = new Bookings()
                {
                    Date       = new DateTime(2020, 5, 26, 12, 0, 0), //Date: 4-17-2020 (US format) 12:00 o' clock
                    RoomNumber = 206,
                    Adults     = 2,
                    Kids       = 3
                };
                bookings.Add(b);

                b = new Bookings()
                {
                    Date       = new DateTime(2020, 5, 26, 12, 0, 0), //Date: 4-17-2020 (US format) 12:00 o' clock
                    RoomNumber = 102,
                    Adults     = 2,
                    Kids       = 0
                };
                bookings.Add(b);

                b = new Bookings()
                {
                    Date       = new DateTime(2020, 5, 26, 12, 0, 0), //Date: 4-17-2020 (US format) 12:00 o' clock
                    RoomNumber = 201,
                    Adults     = 2,
                    Kids       = 1
                };
                bookings.Add(b);

                db.Bookings.AddRange(bookings);
                db.SaveChangesAsync().Wait();

                var c = db.CheckIns.FirstOrDefault();
                if (c == null)
                {
                    log.LogInformation("Seeding checkIn entries");
                    var checkIns = new List <CheckIns>();
                    c = new CheckIns()
                    {
                        Date       = new DateTime(2020, 5, 26, 12, 0, 0), //Date: 4-17-2020 (US format) 12:00 o' clock
                        RoomNumber = 206,
                        Adults     = 1,
                        Kids       = 1,
                    };
                    checkIns.Add(c);

                    c = new CheckIns()
                    {
                        Date       = new DateTime(2020, 5, 26, 12, 0, 0), //Date: 4-17-2020 (US format) 12:00 o' clock
                        RoomNumber = 102,
                        Adults     = 2,
                        Kids       = 0
                    };
                    checkIns.Add(c);

                    c = new CheckIns()
                    {
                        Date       = new DateTime(2020, 5, 26, 12, 0, 0), //Date: 4-17-2020 (US format) 12:00 o' clock
                        RoomNumber = 201,
                        Adults     = 2,
                        Kids       = 0
                    };
                    checkIns.Add(c);


                    db.CheckIns.AddRange(checkIns);
                    db.SaveChangesAsync().Wait();
                }
            }
        }