コード例 #1
0
        public bool UpdateMedicincesToUsersEveryDay()
        {
            List <User> users = _DB.Users.ToList();

            foreach (var user in users)
            {
                List <TimeOfDay> timesToMedicine = _TimeOfDay_DAL.GetListByUserId(user.Id);
                if (timesToMedicine.Count() != 0)
                {
                    List <Models.HMO_db.MedicinesToClient> medicinesToClients = _MedicinesToClient_DAL.GetByUserId(user.Id);
                    ArchiveDAL _archiveDAL = new ArchiveDAL();
                    if (medicinesToClients.Count != 0)
                    {
                        foreach (var item in medicinesToClients)
                        {
                            MedicinesToChild medicinesToChild = new MedicinesToChild()
                            {
                                medicineId   = item.medicinesId,
                                userId       = user.Id,
                                kindOfDosage = item.kindOfDosage,
                                Dosage       = item.Dosage,
                                date         = DateTime.Today
                            };
                            long medicinesToChildId = Add(medicinesToChild);


                            //עבור כל תרופה לילד להכניס לזמן לילד
                            //שליפה מזמנים לילד והצבה עם זמנים לקליינט
                            foreach (var timeToMed in item.TimeToMedicinesForClients)
                            {
                                TimeToMedicinesForChild timeToChild = new TimeToMedicinesForChild()
                                {
                                    idMedicineToChild = medicinesToChildId,
                                    idTimeOfDay       = timesToMedicine.First(t => t.timeCode == timeToMed.timeCode).timeId,//לבדוק
                                    status            = false
                                };

                                //_DB.TimeToMedicinesForChilds.Add(timeToChild);
                                long timeToMedicinesForChildId = _timeToMedicinesForChild_DAL.Add(timeToChild);
                                _archiveDAL.Add(
                                    new ArchiveTakeMedicine
                                {
                                    userId          = user.Id,
                                    medicineToChild = timeToMedicinesForChildId,
                                    date            = DateTime.Now.Date,
                                    onTime          = false
                                });
                            }
                        }
                    }
                }
            }
            if (_DB.SaveChanges() == 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #2
0
 public void AddOrEdit(MedicinesToChild details)
 {
     if (details.Id == 0)
     {
         _MedicinesToChild_DAL.Add(details);
     }
     else
     {
         _MedicinesToChild_DAL.Edit(details);
     }
 }
コード例 #3
0
        //public bool AddListMedicinesToUser(long userId, List<TimeOfDay> listTimeOfDays)
        //public List<DetailsAlert>[] AddListMedicinesToUser(TimeOfAlertForUser timeOfAlertForUser)
        public bool AddListMedicinesToUser(TimeOfAlertForUser timeOfAlertForUser)
        {
            //V
            // List<DetailsAlert>[] _DetailsOfAlert = new List<DetailsAlert>[4];
            //for (int i = 0; i < 4; i++)
            //{
            //    _DetailsOfAlert[i] = new List<DetailsAlert>();

            //}
            List <Models.HMO_db.MedicinesToClient> medicinesToClients = _MedicinesToClient_DAL.GetByUserId(timeOfAlertForUser.snooze.userId);

            if (medicinesToClients.Count() != 0)
            {
                foreach (var item in medicinesToClients)
                {
                    //_DB.Medicines.Add(new Medicine() { medicineId = item.medicineId, midicineName = item.midicineName });
                    MedicinesToChild medicinesToChild = new MedicinesToChild()
                    {
                        medicineId   = item.medicinesId,
                        userId       = timeOfAlertForUser.snooze.userId,
                        kindOfDosage = item.kindOfDosage,
                        Dosage       = item.Dosage,
                        date         = DateTime.Today
                    };
                    long medicinesToChildId = Add(medicinesToChild);//V


                    //V
                    List <TimeToMedicinesForClient> timesToMedicine = _timeToMedicinesForClient_DAL.GetTimeOfDaysByTimeMidicineToClient(item.Id);
                    if (timesToMedicine.Count() != 0)
                    {
                        foreach (var timeList in timesToMedicine)
                        {
                            TimeToMedicinesForChild timeToMedicinesForChild = new TimeToMedicinesForChild()
                            {
                                idMedicineToChild = medicinesToChildId,
                                //idTimeOfDay = listTimeOfDays.Find(t => t.timeCode == item.TimeToMedicinesForClients.Where(tC => tC.TimeOfDay.timeId)).timeId
                                idTimeOfDay = timeOfAlertForUser.timeOfDay.Find(t => t.timeCode == timeList.timeCode).timeId
                            };
                            _timeToMedicinesForChild_DAL.Add(timeToMedicinesForChild);

                            //User user = _User_DAL.GetByIdentity(timeOfAlertForUser.snooze.userId);
                            //DetailsAlert detailsAlert = new DetailsAlert()
                            //{
                            //    UserToken = user.token,
                            //    AlertCount = 0,
                            //    UserName = user.userName,
                            //    snooze = new Snooze
                            //    {
                            //        userId = user.Id,
                            //        snoozePeriod = (int)user.snoozePeriod,
                            //        snoozeCounter = (int)user.snoozeCounter.Value,
                            //    },
                            //    CodeTime = timeList.timeCode
                            //};
                            //_DetailsOfAlert[timeList.timeCode - 1].Add(detailsAlert);
                        }
                        // int codeTimeToClient = item.TimeToMedicinesForClients.FirstOrDefault(t=>t.TimeOfDay.timeCode)
                    }
                }
            }
            else if (_DB.SaveChanges() == 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #4
0
 public void Edit(MedicinesToChild details)
 {
     _DB.Entry(details);
     _DB.SaveChanges();
 }
コード例 #5
0
 public long Add(MedicinesToChild medicinesToChild)
 {
     _DB.MedicinesToChilds.Add(medicinesToChild);
     _DB.SaveChanges();
     return(medicinesToChild.Id);
 }
コード例 #6
0
 public void Add(MedicinesToChild details)
 {
     _DB.MedicinesToChilds.Add(details);
     _DB.SaveChanges();
 }