public void updateAllergies(AllergiesViewModel allergy)
        {
            AllergiesManager update = db.AllergiesManagers.Find(allergy.allergyId);

            update.Allergy_end_date = allergy.Allergy_end_date;
            db.SaveChanges();
        }
        /// <summary>
        /// Accesses the get patient allergies.
        /// </summary>
        /// <param name="patientId">The patient identifier.</param>
        private void AccessGetPatientAllergies(int patientId)
        {
            Patient            p = db.Users.Find(patientId) as Patient;
            AllergiesViewModel viewModel;

            var list = from a in db.AllergiesManagers
                       from allergy in db.Allergies
                       where a.AllergiesManager_PatientId.User_id == p.User_id &&
                       allergy.Allergy_id == a.AllergiesManager_AllergiesId
                       select new
            {
                a.Allergy_start_date,
                a.Allergy_end_date,
                allergy.Allergy_Name,
                allergy.Allergy_id
            };

            foreach (var item in list)
            {
                viewModel = new AllergiesViewModel
                {
                    Allergy_end_date   = item.Allergy_end_date,
                    Allergy_start_date = item.Allergy_start_date,
                    Allergy_Name       = item.Allergy_Name,
                    allergyId          = item.Allergy_id
                };
                allergyList.Add(viewModel);
            }
        }
        public async Task ViewByIdAsyncTest()
        {
            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <AllergiesViewModel>(It.IsAny <Allergies>()))
            .Returns((Allergies source) => new AllergiesViewModel()
            {
                ApplicationUserId = source.ApplicationUserId,
                Milk       = source.Milk,
                Eggs       = source.Eggs,
                Fish       = source.Fish,
                Crustacean = source.Crustacean,
                TreeNuts   = source.TreeNuts,
                Peanuts    = source.Peanuts,
                Wheat      = source.Wheat,
                Soybeans   = source.Soybeans,
            });

            var newAllergy = await this.Service.CreateAsync(
                true,
                true,
                true,
                true,
                false,
                false,
                false,
                false,
                "asd");

            var checkModel = new AllergiesViewModel
            {
                Milk              = true,
                Eggs              = true,
                Fish              = true,
                Crustacean        = true,
                TreeNuts          = false,
                Peanuts           = false,
                Wheat             = false,
                Soybeans          = false,
                ApplicationUserId = "asd",
            };

            var getByUserId = await this.Service.GetByUserIdAsync("asd");

            var viewByUserIdModel = await this.Service.ViewByUserIdAsync <AllergiesViewModel>(getByUserId.ApplicationUserId);

            Assert.Same(checkModel, viewByUserIdModel);
        }
 public void UpdateAllergies(AllergiesViewModel allergy)
 {
     impPatient.updateAllergies(allergy);
 }