Пример #1
0
        public virtual TripModel PrepareModel(TripModel model, Trip entity, bool excludeProperties = false)
        {
            if (null != entity)
            {
                model = model ?? entity.ToModel <TripModel>();

                PrepareConsignmentOrderSearchModel(model.ConsignmentOrderSearchModel, entity);
            }

            if (null == model)
            {
                model = new TripModel
                {
                    SerialNum = CommonHelper.GenerateSerialNumber()
                }
            }
            ;

            PrepareModel(ref model);
            baseAdminModelFactory.PrepareCars(model.AvailableCars, defaultItemText: localizationService.GetResource("Admin.Common.Select"));
            baseAdminModelFactory.PrepareDrivers(model.AvailableDrivers, defaultItemText: localizationService.GetResource("Admin.Common.Select"));
            baseAdminModelFactory.PrepareFeeCategories(model.AvaliableFeeCategories, withSpecialDefaultItem: false);

            if (model.Fees.Count != model.AvaliableFeeCategories.Count)
            {
                model.Fees.Clear();
                foreach (var item in model.AvaliableFeeCategories)
                {
                    model.Fees.Add(new FeeModel {
                        CategoryId = int.Parse(item.Value)
                    });
                }
            }

            return(model);
        }