public static PortfolioViewModel Create(string id, List <MedicineObject> medicines)
        {
            var v = new PortfolioViewModel()
            {
                ID = id
            };

            foreach (var m in medicines)
            {
                v.MedicinesInUse.Add(MedicineViewModelFactory.Create(m));
            }

            return(v);
        }
Beispiel #2
0
        public static EffectViewModel Create(EffectObject o)
        {
            var v = new EffectViewModel
            {
                ID   = o?.DbRecord.ID,
                Name = o?.DbRecord.Name,
            };

            if (o is null)
            {
                return(v);
            }
            v.ValidFrom = setNullIfExtremum(o.DbRecord.ValidFrom);
            v.ValidTo   = setNullIfExtremum(o.DbRecord.ValidTo);
            foreach (var c in o.UsesInMedicines)
            {
                var medicine = MedicineViewModelFactory.Create(c);
                v.UsedInMedicines.Add(medicine);
            }
            return(v);
        }
        public static CategoryViewModel Create(CategoryObject o)
        {
            var v = new CategoryViewModel()
            {
                ID           = o?.DbRecord.ID,
                UserID       = o?.DbRecord.UserID,
                CategoryName = o?.DbRecord.CategoryName
            };

            if (o is null)
            {
                return(v);
            }
            v.ValidFrom = setNullIfExtremum(o.DbRecord.ValidFrom);
            v.ValidTo   = setNullIfExtremum(o.DbRecord.ValidTo);
            foreach (var c in o.MedicinesWithCategory)
            {
                var medicine = MedicineViewModelFactory.Create(c);
                v.MedicinesWithCategory.Add(medicine);
            }

            return(v);
        }
Beispiel #4
0
        public MedicineViewModelsList(IPaginatedList <MedicineObject> list, string sortOrder = null)
        {
            if (list is null)
            {
                return;
            }
            PageIndex  = list.PageIndex;
            TotalPages = list.TotalPages;
            var catalogues = new List <MedicineViewModel>();
            IOrderedEnumerable <MedicineViewModel> ordered;

            foreach (var e in list)
            {
                catalogues.Add(MedicineViewModelFactory.Create(e));
            }

            switch (sortOrder)
            {
            case "name_desc":
                ordered = catalogues.OrderByDescending(s => s.Name);
                break;

            case "atc_code":
                ordered = catalogues.OrderBy(s => s.AtcCode);
                break;

            case "atc_code_desc":
                ordered = catalogues.OrderByDescending(s => s.AtcCode);
                break;

            case "form_of_injecton":
                ordered = catalogues.OrderBy(s => s.FormOfInjection);
                break;

            case "form_of_injecton_desc":
                ordered = catalogues.OrderByDescending(s => s.FormOfInjection);
                break;

            case "strength":
                ordered = catalogues.OrderBy(s => s.Strength);
                break;

            case "strength_desc":
                ordered = catalogues.OrderByDescending(s => s.Strength);
                break;

            case "manufacturer":
                ordered = catalogues.OrderBy(s => s.Manufacturer);
                break;

            case "manufacturer_desc":
                ordered = catalogues.OrderByDescending(s => s.Manufacturer);
                break;

            case "legal_status":
                ordered = catalogues.OrderBy(s => s.LegalStatus);
                break;

            case "legal_status_desc":
                ordered = catalogues.OrderByDescending(s => s.LegalStatus);
                break;

            case "reimbursement":
                ordered = catalogues.OrderBy(s => s.Reimbursement);
                break;

            case "reimbursement_desc":
                ordered = catalogues.OrderByDescending(s => s.Reimbursement);
                break;

            case "validFrom":
                ordered = catalogues.OrderBy(s => s.ValidFrom);
                break;

            case "validFrom_desc":
                ordered = catalogues.OrderByDescending(s => s.ValidFrom);
                break;

            case "validTo":
                ordered = catalogues.OrderBy(s => s.ValidTo);
                break;

            case "validTo_desc":
                ordered = catalogues.OrderByDescending(s => s.ValidTo);
                break;

            default:
                ordered = catalogues.OrderBy(s => s.Name);
                break;
            }
            AddRange(ordered);
        }