Example #1
0
        public void UpdateArrivalStatistics(int patientId, int doctorId, bool isPatientArrived, DateTime date)
        {
            using (var context = new PolyclinicDBContext())
            {
                IQueryable query   = context.Ticket.AsNoTracking();
                var        tickets = from t in context.Ticket
                                     where t.PatientsId == patientId
                                     where t.DoctorsId == doctorId
                                     where t.IsArrived == false
                                     where t.VisitingDateAndTime == date
                                     select t;
                Ticket ticket = tickets.ToList()[0];
                ticket.IsArrived = isPatientArrived;

                var statistics = from s in context.VisitorStatistics
                                 where s.DocId == doctorId
                                 select s;
                foreach (var statistic in statistics)
                {
                    if (statistic.Date.ToShortDateString() == statistic.Date.ToShortDateString())
                    {
                        statistic.ArrivedPatients    += isPatientArrived == true ? 1 : 0;
                        statistic.NonArrivedPatients += isPatientArrived == false ? 1 : 0;
                        break;
                    }
                }
                context.SaveChanges();
            }
        }
        public void SetRooms(List <int> rooms, int specializationId)
        {
            if (rooms is null)
            {
                throw new ArgumentNullException(String.Format("{0} is null", nameof(rooms)));
            }
            ///asdasd
            using (var context = new PolyclinicDBContext())
            {
                foreach (int roomNum in rooms)
                {
                    Room room = new Room {
                        RoomNumber = roomNum, SpecId = specializationId, RoomId = 0
                    };
                    context.Room.Add(room);
                }

                context.SaveChanges();
            }
        }