コード例 #1
0
        public void CreateTest()
        {
            var r = GetRandom.Object <CatalogueDbRecord>();
            var o = MedicineObjectFactory.Create(r.ID, r.CatalogueName, r.Description, r.ValidFrom, r.ValidTo);

            Assert.IsInstanceOfType(o, typeof(MedicineObject));
            testVariables(o.DbRecord, r.ID, r.CatalogueName, r.Description, r.ValidFrom, r.ValidTo);
        }
コード例 #2
0
        public void CreateTest()
        {
            var r = GetRandom.Object <MedicineDbRecord>();
            var o = MedicineObjectFactory.Create(r.ID, r.Name, r.AtcCode, r.FormOfInjection, r.Strength, r.Manufacturer,
                                                 r.LegalStatus, r.Reimbursement, r.Spc, r.Pil, r.ValidFrom, r.ValidTo);

            Assert.IsInstanceOfType(o, typeof(MedicineObject));
            testVariables(o.DbRecord, r.ID, r.Name, r.AtcCode, r.FormOfInjection, r.Strength, r.Manufacturer,
                          r.LegalStatus, r.Reimbursement, r.Spc, r.Pil, r.ValidFrom, r.ValidTo);
        }
コード例 #3
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create([Bind(properties)] MedicineViewModel c)
        {
            if (!ModelState.IsValid)
            {
                return(View(c));
            }
            c.ID = Guid.NewGuid().ToString();
            var o = MedicineObjectFactory.Create(c.ID, c.Name, c.AtcCode, c.FormOfInjection, c.Strength, c.Manufacturer,
                                                 c.LegalStatus, c.Reimbursment, c.Spc, c.Pil, c.ValidFrom, c.ValidTo);
            await repository.AddObject(o);

            return(RedirectToAction("Index"));
        }
コード例 #4
0
        public async Task <List <MedicineObject> > GetMedicines(string userId)
        {
            if (userId is null)
            {
                return(null);
            }
            var portfolioObjects = await dbSet.Include(x => x.Medicine).Where(x => x.UserID == userId)
                                   .AsNoTracking().ToListAsync();

            List <MedicineObject> medicines = new List <MedicineObject>();

            foreach (var m in portfolioObjects)
            {
                var mdb = await dbSetMedicines.FirstOrDefaultAsync(x => x.ID == m.MedicineID);

                medicines.Add(MedicineObjectFactory.Create(mdb.ID, mdb.Name, mdb.AtcCode, mdb.FormOfInjection, mdb.Strength,
                                                           mdb.Manufacturer, mdb.LegalStatus, mdb.Reimbursement, mdb.Spc, mdb.Pil, mdb.ValidFrom, mdb.ValidTo));
            }
            return(medicines);
        }