Esempio n. 1
0
        public ActionResult CheckIn(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var book = db.Books.Find(id);

            if (book == null)
            {
                return(HttpNotFound());
            }
            var    userId    = User.Identity.GetUserId();
            Patron patron    = db.Patrons.Single(p => p.UserId == userId);
            var    checkinVM = new CheckInViewModel
            {
                TimeCheckedIn = DateTime.Now,
                PatronId      = patron.PatronId,
                PatronName    = patron.PatronName,
                BookTitle     = book.Title,
                BookId        = book.BookId
            };

            return(View(checkinVM));
        }
        public IActionResult Create(CheckInViewModel checkInViewModel)
        {
            var user = HttpContext.Session.GetObjectFromJson <User>("user");

            if (user == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            //TODO: make checkin here
            //get current user from session
            //and do checkin operation

            Random rand = new Random();
            string code = rand.Next(100000, 999999).ToString();

            db.Reservation.Add(
                new Reservation {
                UserId = user.Id,
                GymId  = checkInViewModel.GymId,
                Code   = code
            }
                );
            db.SaveChanges();

            return(RedirectToAction("Index", "CheckIn"));
        }
        public IActionResult CheckIn(int barcode)
        {
            var date     = DateTime.Now;
            var dateTime = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, 0).AddHours(-5);

            var uploadDataBaseLogic             = new UploadDataBaseLogic(_context);
            List <BarcodeUser>        users     = _context.BarcodeUsers.Where(i => i.CheckedIn == true).ToList();
            BarcodeUser               newUser   = _context.BarcodeUsers.Where(i => i.Barcode == barcode).FirstOrDefault();
            List <CheckInTimes>       times     = _context.CheckInTimes.OrderByDescending(i => i.Barcode).ToList();
            IEnumerable <BarcodeUser> userNames = _context.BarcodeUsers.OrderBy(c => c.Name).ToList();

            ViewBag.Error = "";



            if (newUser == null)
            {
                ViewBag.Error = "Barcode not found";

                return(View(new CheckInViewModel(userNames)));
            }
            if (newUser != null)
            {
                CheckInViewModel checkInViewModel = new CheckInViewModel(userNames)
                {
                    Users            = users,
                    NewUser          = newUser,
                    UserCheckInTimes = times,
                };
                uploadDataBaseLogic.CheckIn(barcode, dateTime);
                return(View(checkInViewModel));
            }

            return(View());
        }
Esempio n. 4
0
        public void CheckInVehicle(CheckInViewModel newVehicle)
        {
            Vehicle v = Context.Vehicles.Find(newVehicle.Id);

            //Context.Entry(v).State = EntityState.Modified;

            foreach (PropertyInfo p in typeof(Vehicle).GetProperties())
            {
                PropertyInfo vehicleproperty    = typeof(Vehicle).GetProperty(p.Name);
                PropertyInfo newvehicleproperty = typeof(CheckInViewModel).GetProperty(p.Name);
                if (newvehicleproperty != null)
                {
                    if (newvehicleproperty.GetValue(newVehicle) != null)
                    {
                        vehicleproperty.SetValue(v, newvehicleproperty.GetValue(newVehicle));
                    }
                }
            }

            if (!newVehicle.InTime.HasValue) // server side check for inTime
            {
                v.InTime = DateTime.Now;
            }

            if (v.InTime >= (newVehicle.OutTime ?? default(DateTime)))
            {
                v.OutTime = null;
            }

            //Context.Vehicles.Find(newVehicle.Id) = v;

            Context.SaveChanges();
        }
        public async Task <IActionResult> CheckIn([Bind("Id,Type,LicenseNumber,Color,Model,NumberOfWheels, MemberID")] CheckInViewModel vehicle)
        {
            if (ModelState.IsValid)
            {
                var parkedVehicle = new ParkedVehicle
                {
                    Id            = vehicle.Id,
                    Color         = vehicle.Color,
                    LicenseNumber = vehicle.LicenseNumber,
                    Model         = vehicle.Model,

                    NumberOfWheels   = vehicle.NumberOfWheels,
                    TimeStampCheckIn = DateTime.Now,

                    MemberId      = vehicle.MemberID,
                    VehicleTypeId = vehicle.Type
                };

                if (IsLicenceNumberCheckedIn(vehicle.LicenseNumber))
                {
                    vehicle.Types = await GetTypesAsync();

                    vehicle.ErrorMessage = GetLicenseAlreadyParkedErrorMsg(vehicle.LicenseNumber);
                    return(View(vehicle));
                }

                _context.Add(parkedVehicle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(ListGarage)));
            }
            return(View(vehicle));
        }
Esempio n. 6
0
        public ActionResult Index(CheckInViewModel checkin)
        {
            checkin.BranchesViewList = new List <Branch>(branchRepo.GetAllIncludingCheckedOutBranch());

            if (!Holding.IsBarcodeValid(checkin.Barcode))
            {
                ModelState.AddModelError(ModelKey, "Invalid holding barcode format.");
                return(View(checkin));
            }

            var holding = HoldingsControllerUtil.FindByBarcode(holdingRepo, checkin.Barcode);

            if (holding == null)
            {
                ModelState.AddModelError(ModelKey, "Invalid holding barcode.");
                return(View(checkin));
            }
            if (!holding.IsCheckedOut)
            {
                ModelState.AddModelError(ModelKey, "Holding is already checked in.");
                return(View(checkin));
            }

            holding.CheckIn(TimeService.Now, checkin.BranchId);
            holdingRepo.Save(holding);

            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
        public ActionResult CheckIn(CheckInViewModel chckin)
        {
            bool isvacant = false;
            int  roomno   = chckin.RoomNos[0];
            Room room;

            using (HotelManagmentEntities1 db = new HotelManagmentEntities1())
            {
                isvacant = db.Rooms.Where(w => w.RoomNo == roomno).Select(s => s.IsVacant).FirstOrDefault();
                room     = db.Rooms.Where(w => w.RoomNo == roomno).FirstOrDefault();
                if (isvacant)
                {
                    ChckIn chkin = new ChckIn()
                    {
                        RoomNo         = roomno,
                        GuestName      = chckin.GuestName,
                        CheckinDate    = chckin.CheckInDate.ToString(),
                        PurposeOfVisit = chckin.Purpose,
                        Deposit        = chckin.Deposit,
                        RoomRent       = chckin.Rent
                    };
                    room.IsVacant = false;
                    db.ChckIns.Add(chkin);
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("RoomListing", "Login"));
        }
Esempio n. 8
0
        public bool CheckIn(CheckInViewModel checkInViewModel, DXVcsBranch targetBranch, bool isNew)
        {
            Logger.AddInfo("CheckInCommand. Perform checkin file: " + checkInViewModel.FilePath);
            try {
                IDXVcsRepository repository      = DXVcsRepositoryFactory.Create(Port.VcsServer);
                string           filePath        = GetFilePathForBranch(checkInViewModel.FilePath, targetBranch);
                string           vcsOriginalPath = GetMergeVcsPathByTargetPath(filePath, targetBranch);

                if (isNew)
                {
                    repository.AddFile(vcsOriginalPath, File.ReadAllBytes(filePath), checkInViewModel.Comment);
                }
                else
                {
                    repository.CheckInFile(vcsOriginalPath, filePath, checkInViewModel.Comment);
                }
                if (checkInViewModel.StaysChecked)
                {
                    repository.CheckOutFile(vcsOriginalPath, filePath, checkInViewModel.Comment);
                }
            }
            catch (Exception e) {
                Logger.AddError("CheckInCommand. CheckIn failed.", e);
                return(false);
            }
            return(true);
        }
Esempio n. 9
0
        public ActionResult CheckMeIn(CheckInViewModel form)
        {
            if (ModelState.IsValid)
            {
                CheckIn checkIn = new CheckIn();
                checkIn.Text            = form.Text;
                checkIn.Latitude        = form.Latitude;
                checkIn.Longitude       = form.Longitude;
                checkIn.Timezone        = (decimal)Session[Functions.Settings.Session.TIMEZONE];
                checkIn.CreatedDateTime = DateTime.Now;
                checkIn.IsDeleted       = false;
                checkIn.UserID          = User.Identity.GetUserId();

                using (StormChaseCheckInEntities db = new StormChaseCheckInEntities())
                {
                    db.Database.Connection.Open();

                    db.CheckIns.Add(checkIn);
                    db.SaveChanges();
                }

                return(RedirectToAction("MyCheckIns", "Home"));
            }

            return(View(form));
        }
Esempio n. 10
0
        public ActionResult Checkin(int?id)
        {
            if (Request.IsAjaxRequest())
            {
                if (id != null)
                {
                    Vehicle          v = Garage.GetVehicle(id.Value);
                    CheckInViewModel checkinviewmodel = new CheckInViewModel();


                    foreach (PropertyInfo p in typeof(CheckInViewModel).GetProperties())
                    {
                        PropertyInfo modelproperty   = typeof(CheckInViewModel).GetProperty(p.Name);
                        PropertyInfo vehicleproperty = typeof(Vehicle).GetProperty(p.Name);

                        if (vehicleproperty != null)
                        {
                            if (vehicleproperty.GetValue(v) != null)
                            {
                                modelproperty.SetValue(checkinviewmodel, vehicleproperty.GetValue(v));
                            }
                        }
                    }

                    checkinviewmodel.vehicle = v;

                    return(PartialView("Checkin", checkinviewmodel));
                }
                else
                {
                    return(PartialView("Create", new Vehicle()));
                }
            }
            return(RedirectToAction("Index"));
        }
        public JsonResult GetUserCheckIn()
        {
            var viewModel = new CheckInViewModel();
            var events    = new List <CheckInViewModel>();
            //Get check ins
            string             user     = Session["username"].ToString();
            List <CheckInDate> checkins = new List <CheckInDate>();

            checkins = smokeFreeDB.CheckInDate.Where(c => c.userName == user).ToList();

            for (var i = 0; i < checkins.Count(); i++)
            {
                var startDateStr = checkins[i].checkInDate.Date.ToString("yyyy-MM-dd");
                var endDateStr   = checkins[i].checkInDate.AddDays(1).Date.ToString("yyyy-MM-dd");
                events.Add(new CheckInViewModel()
                {
                    startStr = startDateStr,
                    endStr   = endDateStr,
                    allDay   = true,
                    display  = "background",
                    color    = "#d1ffc9"
                });
            }


            return(new JsonResult {
                Data = events.ToArray(), JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Esempio n. 12
0
        public async Task <BookDetail> CheckInBook(CheckInViewModel model)
        {
            Guid.TryParse(model.BookDetailId, out Guid bookDetailId);
            var result = await _book.GetBookById(bookDetailId);

            result.ActualReturnDate = DateTime.Now;
            result.Fine             = model.Fine;
            return(await _book.UpdateAsync(result));
        }
Esempio n. 13
0
        // GET: CheckIn
        public ActionResult Index()
        {
            var model = new CheckInViewModel
            {
                BranchesViewList = new List <Branch>(branchesService.AllBranchesIncludingVirtual())
            };

            return(View(model));
        }
        // GET: ParkedVehicles/Check In
        public async Task <IActionResult> CheckIn()
        {
            var res = new CheckInViewModel()
            {
                Types   = await GetTypesAsync(),
                Members = await GetMembersAsync()
            };

            return(View(res));
        }
Esempio n. 15
0
        public ActionResult Checkin([Bind(Include = "Id, InTime, OutTime, Checkedin")] CheckInViewModel newVehicle)
        {
            if (ModelState.IsValid && Request.IsAjaxRequest())
            {
                Garage.CheckInVehicle(newVehicle);

                return(Json(new { type = true, message = "Vehicle Checked in!" }));
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 16
0
        public void ValidatesBarcode()
        {
            var checkInService = new CheckInService(context, holdingsServiceMock.Object);
            var checkin        = new CheckInViewModel {
                Barcode = "QA1231"
            };

            Assert.False(checkInService.Checkin(checkin));

            Assert.Equal("Invalid holding barcode format: QA1231", checkInService.ErrorMessages.First());
        }
Esempio n. 17
0
        public void ChecksInBook()
        {
            var holding        = SaveCheckedOutHoldingWithClassification(context, "QA123");
            var checkInService = new CheckInService(context, holdingsServiceMock.Object);
            var checkin        = new CheckInViewModel {
                Barcode = "QA123:1", BranchId = 42
            };

            Assert.True(checkInService.Checkin(checkin));

            holdingsServiceMock.Verify(s => s.CheckIn(holding, 42));
        }
        public CheckInControllerTest(DbContextFixture fixture)
        {
            fixture.Seed();
            var context = new LibraryContext(fixture.ContextOptions);

            controller       = new CheckInController(context, checkInServiceMock.Object, new BranchesService(context));
            checkinViewModel = new CheckInViewModel
            {
                Barcode  = "QA123:1",
                BranchId = 1
            };
        }
Esempio n. 19
0
        public ActionResult Index(CheckInViewModel checkin)
        {
            checkin.BranchesViewList = new List <Branch>(branchesService.AllBranchesIncludingVirtual());

            if (!checkInService.Checkin(checkin))
            {
                AddModelErrors(checkInService.ErrorMessages, ModelKey);
                return(View(checkin));
            }

            // TODO this is broke (?)
            return(RedirectToAction("Index"));
        }
Esempio n. 20
0
        public async Task <IActionResult> CheckIn(CheckInViewModel model, string id)
        {
            Guid.TryParse(id, out Guid data);
            var book = await _book.GetBookById(data);

            ViewBag.Book = book;

            var result = await _bookDetail.CheckInBook(model);

            await _book.UpdateBookStatus(result.BookId, BookStatus.CheckIn);

            return(Ok());
        }
Esempio n. 21
0
        public void ValidatesHoldingRetrieval()
        {
            SavePatronWithId(context, 5);
            var checkInService = new CheckInService(context, holdingsServiceMock.Object);
            var checkin        = new CheckInViewModel {
                Barcode = "QA123:1"
            };

            Assert.False(checkInService.Checkin(checkin));

            Assert.Equal("Holding with barcode QA123:1 not found",
                         checkInService.ErrorMessages.First());
        }
Esempio n. 22
0
 public ActionResult CheckIn(CheckInViewModel cvm)
 {
     if (ModelState.IsValid)
     {
         var patron = db.Patrons.Find(cvm.PatronId);
         var book   = db.Books.Single(x => x.BookId == cvm.BookId);
         patron.Books.Add(book);
         book.PatronId        = null;
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("PatronProfile", "Account"));
     }
     return(View(cvm));
 }
Esempio n. 23
0
        public void ValidatesHoldingAvailability()
        {
            SaveCheckedInHoldingWithClassification(context, "QA123");
            SavePatronWithId(context, 1);
            var checkInService = new CheckInService(context, holdingsServiceMock.Object);
            var checkin        = new CheckInViewModel {
                Barcode = "QA123:1"
            };

            Assert.False(checkInService.Checkin(checkin));

            Assert.Equal("Holding with barcode QA123:1 is already checked in",
                         checkInService.ErrorMessages.First());
        }
        public void Initialize()
        {
            holdingRepo = new InMemoryRepository <Holding>();

            branchRepo        = new InMemoryRepository <Branch>();
            someValidBranchId = branchRepo.Create(new Branch()
            {
                Name = "b"
            });

            patronRepo = new InMemoryRepository <Patron>();

            controller = new CheckInController(branchRepo, holdingRepo, patronRepo);
            checkin    = new CheckInViewModel();
        }
Esempio n. 25
0
        public IActionResult CheckIn()
        {
            //get a list of all clients.
            var clients = _context.Clients.ToList();

            var model = new CheckInViewModel
            {
                Clients = clients.Select(c =>
                                         new SelectListItem()
                {
                    Text = c.Email.ToString()
                }),
            };

            return(View("CheckInView", model));
        }
Esempio n. 26
0
        public ActionResult CheckIn(int id)
        {
            List <int> usersIn = (List <int>)Service.ListUsersIn().Select(x => x.UserID).ToList();

            if (usersIn.Contains(id))
            {
                return(RedirectToAction("Checkout", new { userID = id }));
            }
            //build checkin viewmodel
            User temp = Service.GetCompleteUserByID(id);

            ViewBag.UserName = temp.FirstName + " " + temp.LastName;
            CheckInViewModel ret = new CheckInViewModel(id, Service.ListAvailableVisitTypes(id), temp.Classes,
                                                        temp.Comments);

            return(View(ret));
        }
        public IActionResult CheckIn(int id)
        {
            var gym_owner = HttpContext.Session.GetObjectFromJson <User>("gym_owner");

            if (gym_owner == null)
            {
                return(RedirectToAction("Index", "Auth"));
            }
            Reservation reservation = db.Reservation.Where(x => x.Id == id)
                                      .Include(x => x.User)
                                      .FirstOrDefault();

            CheckInViewModel checkInViewModel = new CheckInViewModel {
                Reservation = reservation
            };

            return(View(checkInViewModel));
        }
Esempio n. 28
0
        public virtual bool Checkin(CheckInViewModel checkin)
        {
            pipelineValidator.Validate(new List <Validator>
            {
                new BarcodeValidator(context, checkin.Barcode),
                new HoldingRetrievalValidator(context, checkin.Barcode),
                new NotValidator(new HoldingAvailableValidator(context))
            });
            if (!pipelineValidator.IsValid())
            {
                return(false);
            }

            var holding = (Holding)pipelineValidator.Data[HoldingKey];

            holdingsService.CheckIn(holding, checkin.BranchId);
            return(true);
        }
Esempio n. 29
0
        void CheckIn(CheckInTarget target)
        {
            if (IsSingleSelection)
            {
                Logger.AddInfo("CheckInCommand. Start single check in.");

                var           model  = new CheckInViewModel(GetCheckInPath(target, SelectedItem.Path), false);
                MessageResult result = GetService <IDialogService>(Checkinwindow).ShowDialog(MessageButton.OKCancel, "Check in", model);
                if (result == MessageResult.OK)
                {
                    var helper = new MergeHelper(this);
                    helper.CheckIn(new CheckInViewModel(SelectedItem.Path, model.StaysChecked)
                    {
                        Comment = model.Comment
                    }, GetCheckInBranch(target), SelectedItem.IsNew);
                    SelectedItem.IsChecked = model.StaysChecked;
                }

                Logger.AddInfo("CheckInCommand. End single check in.");
            }
            else
            {
                Logger.AddInfo("CheckInCommand. Start multiple check in.");

                var model  = new CheckInViewModel(GetCheckInPath(target, Solution.Path), false);
                var result = GetService <IDialogService>(MultipleCheckinWindow).ShowDialog(MessageButton.OKCancel, "Multiple Check in", model);
                if (result == MessageResult.OK)
                {
                    var helper = new MergeHelper(this);
                    foreach (var item in SelectedItems)
                    {
                        var currentFileModel = new CheckInViewModel(item.Path, model.StaysChecked)
                        {
                            Comment = model.Comment
                        };
                        bool success = helper.CheckIn(currentFileModel, GetCheckInBranch(target), item.IsNew);
                        item.IsChecked = success && model.StaysChecked;
                    }
                }

                Logger.AddInfo("CheckInCommand. End multiple check in.");
            }
            ReloadProject();
        }
Esempio n. 30
0
        private IEnumerable <CheckInViewModel> GetProfissionaisQueFizeramCheckIn(int oportunidadeId)
        {
            var usuario = PixCoreValues.UsuarioLogado;
            var keyUrl  = ConfigurationManager.AppSettings["UrlAPI"].ToString();
            var url     = keyUrl + "/Seguranca/WpCheckIn/BuscarPorIdExterno/" + usuario.idCliente + "/" +
                          PixCoreValues.UsuarioLogado.IdUsuario;

            var envio = new
            {
                usuario.idCliente,
                idExterno = oportunidadeId,
            };

            var helper = new ServiceHelper();
            var result = helper.Post <IEnumerable <CheckIn> >(url, envio);

            var profissionais = GetProfissionais(result.Select(x => x.IdUsuario));
            var users         = GetUsers(profissionais.Select(x => x.Profissional.IdUsuario));
            var extratos      = GetExtratos(oportunidadeId);

            IList <CheckInViewModel> response = new List <CheckInViewModel>();

            foreach (var item in profissionais)
            {
                var user    = users.FirstOrDefault(u => u.ID.Equals(item.Profissional.IdUsuario));
                var ck      = result.FirstOrDefault(c => c.IdUsuario.Equals(item.Profissional.IdUsuario));
                var extrato = extratos.FirstOrDefault(e => e.Destino.Equals(item.Profissional.IdUsuario.ToString()));

                var checkin = new CheckInViewModel()
                {
                    Id              = item.Profissional.ID,
                    OportunidadeId  = oportunidadeId,
                    Hora            = ck.DataCriacao,
                    Nome            = user.Nome,
                    StatusPagamento = (int)extrato.StatusId,
                    IdUsuario       = user.ID,
                };

                response.Add(checkin);
            }

            return(response);
        }