Esempio n. 1
0
        public IHttpActionResult CheckOut(int id)
        {
            using (var db = new vmsDBContext())
            {
                InOuts inout = new InOuts();
                inout.VisitorID = id;
                inout.InTime    = GetCheckInTime(id);
                inout.OutTime   = string.Format("{0:HH:mm tt}", DateTime.Now);
                inout.Status    = "Security Checkout";
                inout.EntryDate = DateTime.Now;

                db.InOuts.Add(inout);
                db.SaveChanges();
            }
            using (var db = new vmsDBContext())
            {
                var inouts = (from inout in db.InOuts
                              where inout.VisitorID.Equals(id) &&
                              inout.Status.Equals("Security Checkin")
                              select inout).SingleOrDefault();
                inouts.OutTime = string.Format("{0:HH:mm tt}", DateTime.Now);
                db.SaveChanges();
            }
            return(Ok("OK"));
        }
Esempio n. 2
0
        private void FilterShow(object parameter)
        {
            var grid = parameter as Grid;

            grid.Visibility = grid.Visibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;

            if (grid.Visibility == Visibility.Collapsed)
            {
                SelectedCostItem         = CostItems.First();
                SelectedRC               = RCs.First();
                SelectedInOut            = InOuts.First();
                SelectedTransportCompany = TransportCompanies.First();
                SelectedNote             = Notes.First();
            }
        }
Esempio n. 3
0
        public HttpResponseMessage Post(VisitorModel entity)
        {
            if (ModelState.IsValid)
            {
                using (var db = new vmsDBContext())
                {
                    Visitors vstr = new Visitors();
                    vstr.Name        = entity.Name;
                    vstr.Guests      = entity.Guests;
                    vstr.Email       = entity.Email;
                    vstr.Phone       = entity.Phone;
                    vstr.IdCard      = entity.IdCard;
                    vstr.Vehicle     = entity.Vehicle;
                    vstr.VehicleNu   = entity.VehicleNu;
                    vstr.Color       = entity.Color;
                    vstr.ParkineZone = entity.ParkineZone;
                    vstr.Building    = entity.Building;
                    vstr.MeeTTo      = entity.MeeTTo;
                    vstr.TokenNo     = entity.TokenNo;
                    vstr.EntryDate   = DateTime.Now;
                    db.Visitors.Add(vstr);
                    db.SaveChanges();

                    //db.Entry(vstr).GetDatabaseValues();

                    InOuts inout = new InOuts();
                    inout.VisitorID = vstr.VisitorID;
                    inout.InTime    = entity.InTime;
                    inout.Status    = "Security Checkin";
                    inout.EntryDate = DateTime.Now;
                    db.InOuts.Add(inout);
                    db.SaveChanges();
                }

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, new { entity });
                return(response);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
Esempio n. 4
0
        private void RefreshFilters()
        {
            if (RCs == null || InOuts == null || TransportCompanies == null || Notes == null)
            {
                return;
            }

            SelectedRC               = RCs.First();
            SelectedInOut            = InOuts.First();
            SelectedTransportCompany = TransportCompanies.First();
            SelectedNote             = Notes.First();

            Filter();

            BC.DataContext.Configuration.AutoDetectChangesEnabled = false;

            RCs.Clear();
            var rcEmpty = new DirectoryRC {
                Name = null
            };

            RCs.Add(rcEmpty);

            foreach (var rc in Costs.Select(c => c.DirectoryRC).Distinct())
            {
                RCs.Add(rc);
            }

            InOuts.Clear();
            InOuts.Add("");

            if (Costs.Any(c => c.IsIncoming))
            {
                InOuts.Add("Приход");
            }

            if (Costs.Any(c => !c.IsIncoming))
            {
                InOuts.Add("Расход");
            }


            TransportCompanies.Clear();
            var transportCompanyEmpty = new DirectoryTransportCompany {
                Name = null
            };

            TransportCompanies.Add(transportCompanyEmpty);

            foreach (var transportCompany in Costs.Select(c => c.DirectoryTransportCompany).Where(t => t != null).Distinct())
            {
                TransportCompanies.Add(transportCompany);
            }


            Notes.Clear();
            var noteEmpty = new DirectoryNote {
                Description = null
            };

            Notes.Add(noteEmpty);

            foreach (var masNotes in Costs.Select(c => c.CurrentNotes.Select(n => n.DirectoryNote)))
            {
                foreach (var note in masNotes)
                {
                    if (!Notes.Contains(note))
                    {
                        Notes.Add(note);
                    }
                }
            }

            OrderNotes();

            BC.DataContext.Configuration.AutoDetectChangesEnabled = true;
        }