Beispiel #1
0
        /// <summary>
        /// 修改模型
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task UpdateModel(ModelDto model)
        {
            var cModel = await _modelRepository.GetAsync(model.Id);

            model.MapTo(cModel);
            await _modelRepository.UpdateAsync(cModel);
        }
Beispiel #2
0
 public ModelsViewModel Get(int?id)
 {
     using (var db = new SmartAutosContext())
     {
         return(ModelDto.ModelViewModelDTO(db.Model.FirstOrDefault(x => x.Id == id)));
     }
 }
Beispiel #3
0
            protected override void Establish_context()
            {
                Mapper.AllowNullDestinationValues = false;
                Mapper.CreateMap<ModelObject, ModelDto>();

                _result = Mapper.Map<ModelObject, ModelDto>(null);
            }
        public virtual ActionResult UpdateModel(ModelDto dto)
        {
            string model = string.Empty, alertMessage = string.Empty;
            bool   isSuccess = true;

            if (!_iModelService.UpdateModel(dto))
            {
                isSuccess = false;
                Danger(Messages.ErrorOccuredDuringProcessing);
            }
            else
            {
                Success(Messages.InsertSuccess);
                model = this.RenderRazorViewToString(IOBALANCEMVC.AdminManagement.Model.Views._ListModel, GetModel());
            }

            alertMessage = this.RenderRazorViewToString(IOBALANCEMVC.Shared.Views._Alerts, string.Empty);
            var jsonResult = new
            {
                isSuccess    = isSuccess,
                alertMessage = alertMessage,
                model        = model
            };

            return(Json(jsonResult, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="saveState"></param>
        /// <returns></returns>
        public ModelDto Query(SaveState saveState)
        {
            var modelDto = new ModelDto();

            return(saveState.OperationState == OperationState.Add ? modelDto :
                   _modelService.Query(saveState.Key));
        }
Beispiel #6
0
            protected override void Establish_context()
            {
                Mapper.Reset();

                var model = new ModelObject
                {
                    BaseDate = new DateTime(2007, 4, 5),
                    Sub      = new ModelSubObject
                    {
                        ProperName = "Some name",
                        SubSub     = new ModelSubSubObject
                        {
                            IAmACoolProperty = "Cool daddy-o"
                        }
                    },
                    Sub2 = new ModelSubObject
                    {
                        ProperName = "Sub 2 name"
                    },
                    SubWithExtraName = new ModelSubObject
                    {
                        ProperName = "Some other name"
                    },
                    SubMissing = new ModelSubObject
                    {
                        ProperName = "I have a missing sub sub object"
                    }
                };

                Mapper.CreateMap <ModelObject, ModelDto>();
                _result = Mapper.Map <ModelObject, ModelDto>(model);
            }
Beispiel #7
0
        public void InsertModel(ModelDto newModelDto)
        {
            var newModel = new Model
            {
                Name        = newModelDto.Name,
                Description = newModelDto.Description,
                Photo       = newModelDto.Photo,
                Cost        = newModelDto.Cost,
                TypeId      = newModelDto.ShoesTypeId,
                Sex         = newModelDto.Sex,
                IsForKids   = newModelDto.IsForKids
            };

            _shoesDataEntities.Models.Add(newModel);
            newModelDto.AvailablesColors.ForEach(dto =>
            {
                var newModelColor = new ModelColor
                {
                    ColorId = dto.ColorId.Value,
                    ModelId = newModel.Id
                };
                _shoesDataEntities.ModelColors.Add(newModelColor);
            });
            SaveChanges();
        }
Beispiel #8
0
        public async Task <IActionResult> EditModel(int id, [FromForm] ModelDto model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Something want wrong while updating model"));
            }

            var modelToEdit = await _modelService.GetModellByIdAsync(id);

            if (modelToEdit == null)
            {
                return(BadRequest("Brand not found"));
            }

            modelToEdit.Name    = model.Name;
            modelToEdit.BrandId = model.BrandId;

            await _modelService.UpdateModelAsync(modelToEdit);

            await _genericRepository.SaveChangesAsync();

            return(Ok(new
            {
                status = 200,
                message = "Model edited successfully"
            }));
        }
Beispiel #9
0
            protected override void Establish_context()
            {
                var model = new ModelObject
                {
                    Blarg              = 10,
                    SomeValue          = "Some value",
                    SomeWeirdSubObject = new ModelSubObject
                    {
                        Narf   = 5,
                        SubSub = new ModelSubSubObject
                        {
                            Norf = 15
                        }
                    },
                    MoreBlarg = "adsfdsaf"
                };

                Mapper
                .CreateMap <ModelObject, ModelDto>()
                .ForMember(dto => dto.Splorg, opt => opt.MapFrom(m => m.Blarg))
                .ForMember(dto => dto.SomeMethod, opt => opt.MapFrom(m => m.IAmSomeMethod()))
                .ForMember(dto => dto.SubNarf, opt => opt.MapFrom(m => m.SomeWeirdSubObject.Narf))
                .ForMember(dto => dto.SubValue, opt => opt.MapFrom(m => m.SomeWeirdSubObject.SomeSubValue()))
                .ForMember(dto => dto.GrandChildInt, opt => opt.MapFrom(m => m.SomeWeirdSubObject.SubSub.Norf))
                .ForMember(dto => dto.GrandChildString, opt => opt.MapFrom(m => m.SomeWeirdSubObject.SubSub.SomeSubSubValue()))
                .ForMember(dto => dto.MoreBlarg, opt => opt.MapFrom(m => m.SomeMethodToGetMoreBlarg()))
                .ForMember(dto => dto.BlargPlus3, opt => opt.MapFrom(m => m.Blarg.Plus(3)))
                .ForMember(dto => dto.BlargMinus2, opt => opt.MapFrom(m => m.Blarg - 2));

                _result = Mapper.Map <ModelObject, ModelDto>(model);
            }
Beispiel #10
0
            protected override void Establish_context()
            {
                Mapper.AllowNullDestinationValues = false;
                Mapper.CreateMap <ModelObject, ModelDto>();

                _result = Mapper.Map <ModelObject, ModelDto>(null);
            }
Beispiel #11
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="array"></param>
        public void Add(ModelDto entity, int[] array)
        {
            using (_unitOfWork)
            {
                var info                 = AutoMapperHelper.Signle <ModelDto, Model>(entity);
                var repository           = _unitOfWork.Repository <Model>();
                var modelFieldRepository = _unitOfWork.Repository <ModelField>();

                foreach (var item in array)
                {
                    var role = new ModelField
                    {
                        ModelFieldId = item
                    };
                    modelFieldRepository.Attach(role);

                    info.ModelFields.Add(role);
                }


                repository.Add(info);

                _unitOfWork.Commit();
            }
        }
        private List <ModelDto> MapNstepModelDto(Segment segment)
        {
            List <ModelDto> models         = new List <ModelDto>();
            Model           parentModel    = segment.Models.FirstOrDefault(m => m.ParentId <= 0);
            ModelDto        parentModelDto = new ModelDto()
            {
                Id         = parentModel.Id,
                SegmentId  = parentModel.SegmentId,
                ModelType  = parentModel.ModelType,
                Name       = parentModel.Name,
                Parameters = new List <ModelParamDto>()
            };

            parentModelDto.Models = segment.Models.Where(m => m.ParentId > 0).Select(m => new ModelDto()
            {
                Id          = m.Id,
                SegmentId   = m.SegmentId,
                BaseModel   = MapBaseModelDto(m.BaseModel),
                BaseModelId = m.BaseModel.Id,
                ModelType   = m.ModelType,
                Name        = m.Name,
                Parameters  = JsonConvert.DeserializeObject <List <ModelParamDto> >(m.ModelConfig).Select(param => new ModelParamDto()
                {
                    BaseModelId      = param.BaseModelId,
                    BaseModelParamId = param.BaseModelParamId,
                    Value            = param.Value
                }).ToList()
            }).ToList();
            models.Add(parentModelDto);
            return(models);
        }
Beispiel #13
0
        public async Task <APIResponse <Model> > Post([FromBody] ModelDto modelDto)
        {
            // Mapping dto with model
            var model = _mapper.Map <Model>(modelDto);

            // Valdate model
            if (!ModelState.IsValid)
            {
                var errors = new List <string>();
                foreach (var state in ModelState)
                {
                    foreach (var error in state.Value.Errors)
                    {
                        errors.Add(error.ErrorMessage);
                    }
                }

                var err = new { errors = errors };

                return(new APIResponse <Model>(400, err, null));
            }

            var modelAdded = await _modelService.AddModelAsync(model);

            if (modelAdded != null)
            {
                return(new APIResponse <Model>(201, "Model is created", modelAdded));
            }
            return(new APIResponse <Model>(204, "Model is not created", modelAdded));
        }
        protected override ModelDto Flatten(ModelObject model)
        {
            if (model == null)
            {
                return(null);
            }

            var dto = new ModelDto {
                BaseDate = model.BaseDate
            };

            if (model.Sub != null)
            {
                dto.SubProperName = model.Sub.ProperName;

                if (model.Sub.SubSub != null)
                {
                    dto.SubSubSubCoolProperty = model.Sub.SubSub.CoolProperty;
                }
            }

            if (model.Sub2 != null)
            {
                dto.Sub2ProperName = model.Sub2?.ProperName;
            }

            if (model.SubWithExtraName != null)
            {
                dto.SubWithExtraNameProperName = model.SubWithExtraName?.ProperName;
            }

            return(dto);
        }
Beispiel #15
0
 public Model CopyFrom(ModelDto dto)
 {
     this.BrandName = dto.BrandName;
     this.ModelName = dto.ModelName;
     BaseCopyFrom <Model>(dto);
     return(this);
 }
Beispiel #16
0
 public ModelDto CopyTo(ModelDto dto)
 {
     dto.BrandName = this.BrandName;
     dto.ModelName = this.ModelName;
     BaseCopyTo <ModelDto>(dto);
     return(dto);
 }
Beispiel #17
0
 protected override void Because_of()
 {
     _model = new ModelObject {
         SomeValue = 2
     };
     _dto = Mapper.Map <ModelObject, ModelDto>(_model);
 }
Beispiel #18
0
            protected override void Because_of()
            {
                var model = new ModelObject {
                    NotAString = 5
                };

                _result = Mapper.Map <ModelObject, ModelDto>(model);
            }
Beispiel #19
0
        public List <ModelDto> GetModels()
        {
            var modelData = _digitalTwinsClient.GetModels(new GetModelsOptions {
                IncludeModelDefinition = true
            }).ToList();

            return(ModelDto.MapFromModelData(modelData));
        }
Beispiel #20
0
            protected override void Establish_context()
            {
                var model = new ModelObject();

                Mapper.CreateMap <ModelObject, ModelDto>();

                _result = Mapper.Map <ModelObject, ModelDto>(model);
            }
Beispiel #21
0
            protected override void Because_of()
            {
                var model = new ModelObject {
                    Value = 42, Value2fff = 42, Value3 = 42, Value4 = 42, Value5 = 42
                };

                _result = Mapper.Map <ModelObject, ModelDto>(model);
            }
Beispiel #22
0
            protected override void Because_of()
            {
                var model = new ModelObject {
                    SomeValue = "Some value"
                };

                _result = Mapper.Map <ModelObject, ModelDto>(model);
            }
Beispiel #23
0
        protected override void Because_of()
        {
            var model = new ModelObject();

            model.Sub = null;

            _result = Mapper.Map <ModelObject, ModelDto>(model);
        }
 private void ReloadShoesModelPicture(ModelDto selectedModel)
 {
     this.shoesPictureBox.Image = null;
     if (selectedModel != null)
     {
         PictureViewUtils.LoadImageToControl(selectedModel.Photo, shoesPictureBox);
     }
 }
Beispiel #25
0
        public async Task <int> UpdateModelAsync(ModelDto model)
        {
            var entity  = _mapper.Map <Model>(model);
            var updated = await _repository.UpdateModelAsync(entity);

            //await _auditEventLogger.LogEventAsync(new ModelUpdatedEvent(model));
            return(updated);
        }
        public async Task <IActionResult> Post([FromBody] ModelDto dto)
        {
            var model = _mapper.Map <Model>(dto);
            await _context.Models.AddAsync(model);

            await _context.SaveChangesAsync();

            return(Ok());
        }
Beispiel #27
0
        public void Model_CRUD()
        {
            var proxy = new ProxyService <DeviceService>(new DeviceService(new ServiceContext()));

            //arrange
            var dto = testUtil.ModelDto();

            //Create
            var rpInsert = proxy.RunAsync(x => x.InsertModel(dto));

            rpInsert.Wait();
            Assert.True(rpInsert.Result.Data > 0);

            //Read
            long identity = rpInsert.Result.Data;
            var  rpGet    = proxy.RunAsync(x => x.GetModel(identity));

            rpGet.Wait();
            Assert.True(rpInsert.Result.Data == rpGet.Result.Data.Id);

            //Update
            var tmpDto = rpGet.Result.Data;

            tmpDto.BrandName = "Name updated!";
            var rpUpdate = proxy.RunAsync(x => x.UpdateModel(tmpDto));

            rpUpdate.Wait();
            var rpUpdateGet = proxy.RunAsync(x => x.GetModel(identity));

            rpUpdateGet.Wait();
            Assert.Equal(rpUpdateGet.Result.Data.BrandName, tmpDto.BrandName);

            //Delete
            var rpDelete = proxy.RunAsync(x => x.DeleteModel(identity));

            rpDelete.Wait();
            var rpDeleteGet = proxy.RunAsync(x => x.GetModel(identity));

            rpDeleteGet.Wait();
            Assert.True(rpDeleteGet.Result.Data == null);

            //List
            var queryDto  = new ModelDto {
            };
            var pagingDto = new PagingDto {
                pageSize = 30, pageNumber = 1
            };
            var rpList = proxy.RunAsync(x => x.ListModel(queryDto, pagingDto));//List

            rpList.Wait();
            Assert.True(rpList?.Result.Data != null && rpList.Result.Data.Any());

            //assert

            //cleaup
            var rpHardDelete = proxy.RunAsync(x => x.DeleteHardModel(identity));
        }
Beispiel #28
0
        public async Task <int> CreateModelAsync(ModelDto model)
        {
            var entity = _mapper.Map <Model>(model);
            var added  = await _repository.AddModelAsync(entity);

            await _auditEventLogger.LogEventAsync(new ModelCreatedEvent(model));

            return(added);
        }
Beispiel #29
0
            protected override void Establish_context()
            {
                var model = new ModelObject();

                Mapper.CreateMap <ModelObject, ModelDto>()
                .ForMember(d => d.SomeCoolValues, opt => opt.MapFrom(s => s.GetSomeCoolValues().Select(x => x.ToString())));

                _result = Mapper.Map <ModelObject, ModelDto>(model);
            }
Beispiel #30
0
        private static ModelDto BuildModel(Guid modelId, Guid netId1, Guid netId2)
        {
            var assets = new List <AssetDto>
            {
                new AssetDto
                {
                    Id          = Guid.NewGuid(),
                    Hostname    = "server10",
                    AssetNumber = 999999,
                },
                new AssetDto
                {
                    Id          = Guid.NewGuid(),
                    Hostname    = "server11",
                    AssetNumber = 000000,
                }
            };

            var model = new ModelDto
            {
                Id            = modelId,
                Vendor        = "foo vendor",
                ModelNumber   = "foo model number",
                Height        = 4,
                DisplayColor  = "#000fff",
                EthernetPorts = 2,
                PowerPorts    = 2,
                Cpu           = "foo cpu",
                Memory        = 16,
                Storage       = "foo storage",
                Comment       = "foo comment",
                Assets        = assets
            };
            var networks = new List <ModelNetworkPortDto>
            {
                new ModelNetworkPortDto
                {
                    Id      = netId1,
                    Model   = model,
                    ModelId = modelId,
                    Name    = "eth0",
                    Number  = 1
                },
                new ModelNetworkPortDto
                {
                    Id      = netId2,
                    Model   = model,
                    ModelId = modelId,
                    Name    = "eth1",
                    Number  = 2
                }
            };

            model.NetworkPorts = networks;
            return(model);
        }
Beispiel #31
0
            protected override void Establish_context()
            {
                Mapper.CreateMap <ModelObject, ModelDto>();

                var model = new ModelObject();

                model.SomeValue = 46;

                _result = Mapper.Map <ModelObject, ModelDto>(model);
            }
            protected override void Establish_context()
            {
                Mapper.AddFormatter<HardEncoder>();
                Mapper.AddFormatter(new SoftEncoder());
                Mapper.AddFormatter(typeof(RokkenEncoder));
                Mapper.AddFormatExpression(context => context.SourceValue + " Medium");

                Mapper.CreateMap<ModelObject, ModelDto>();

                var modelObject = new ModelObject { Value = 14 };

                _modelDto = Mapper.Map<ModelObject, ModelDto>(modelObject);
            }
            protected override void Establish_context()
            {
                var model = new ModelObject
                    {
                        Blarg = 10,
                        SomeValue = "Some value",
                        SomeWeirdSubObject = new ModelSubObject
                            {
                                Narf = 5,
                                SubSub = new ModelSubSubObject
                                    {
                                        Norf = 15
                                    }
                            },
                        MoreBlarg = "adsfdsaf"
                    };
                Mapper
                    .CreateMap<ModelObject, ModelDto>()
                    .ForMember(dto => dto.Splorg, opt => opt.MapFrom(m => m.Blarg))
                    .ForMember(dto => dto.SomeMethod, opt => opt.MapFrom(m => m.IAmSomeMethod()))
                    .ForMember(dto => dto.SubNarf, opt => opt.MapFrom(m => m.SomeWeirdSubObject.Narf))
                    .ForMember(dto => dto.SubValue, opt => opt.MapFrom(m => m.SomeWeirdSubObject.SomeSubValue()))
                    .ForMember(dto => dto.GrandChildInt, opt => opt.MapFrom(m => m.SomeWeirdSubObject.SubSub.Norf))
                    .ForMember(dto => dto.GrandChildString, opt => opt.MapFrom(m => m.SomeWeirdSubObject.SubSub.SomeSubSubValue()))
                    .ForMember(dto => dto.MoreBlarg, opt => opt.MapFrom(m => m.SomeMethodToGetMoreBlarg()))
                    .ForMember(dto => dto.BlargPlus3, opt => opt.MapFrom(m => m.Blarg.Plus(3)))
                    .ForMember(dto => dto.BlargMinus2, opt => opt.MapFrom(m => m.Blarg - 2));

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
        public void FilterRemovesAppropriateRowsFromMyInventoryOnEachCallAndResetsAfterClearingFilter()
        {
            var athlete1 = new AthleteDto() { FirstNamek__BackingField = "Jeff", LastNamek__BackingField = "Artis-Gray", Nicknamek__BackingField = "JArtis-Gray", Genderk__BackingField = 'M', TrainerSizeMk__BackingField = 14, TrainerSizeWk__BackingField = 12, SpikeSizeMk__BackingField = 14, SpikeSizeWk__BackingField = 12, Notesk__BackingField = "Notes about Jeff Artis-Gray", Statusk__BackingField = "Future", Inventoryk__BackingField = new List<InventoryItemDto>() };
            var athlete2 = new AthleteDto() { FirstNamek__BackingField = "Darren", LastNamek__BackingField = "Barlow", Nicknamek__BackingField = "DBarlow", Genderk__BackingField = 'M', TrainerSizeMk__BackingField = 14, TrainerSizeWk__BackingField = 12, SpikeSizeMk__BackingField = 14, SpikeSizeWk__BackingField = 12, Notesk__BackingField = "Notes about Darren Barlow", Statusk__BackingField = "Past", Inventoryk__BackingField = new List<InventoryItemDto>() };
            var athlete3 = new AthleteDto() { FirstNamek__BackingField = "Jared", LastNamek__BackingField = "Berman", Nicknamek__BackingField = "JBerman", Genderk__BackingField = 'M', TrainerSizeMk__BackingField = 13, TrainerSizeWk__BackingField = 11, SpikeSizeMk__BackingField = 13, SpikeSizeWk__BackingField = 11, Notesk__BackingField = "Notes about Jared Berman", Statusk__BackingField = "Past", Inventoryk__BackingField = new List<InventoryItemDto>() };

            var model1 = new ModelDto() { ModelNumberk__BackingField = "524395-386", ModelNamek__BackingField = "Air Pegasus+ 29 Trail", Typek__BackingField = "Running", Pricek__BackingField = 105, Colork__BackingField = "Silver Sage/Team Red/University Red/Total Orange", IsDiscontinuedk__BackingField = false };
            var model2 = new ModelDto() { ModelNumberk__BackingField = "524395-038", ModelNamek__BackingField = "Air Pegasus+ 29 Trail", Typek__BackingField = "Running", Pricek__BackingField = 105, Colork__BackingField = "Cool Grey/Total Orange/Signal Blue/Electric Green", IsDiscontinuedk__BackingField = false };

            var inventoryItem1 = new InventoryItemDto() { ModelDtok__BackingField = model1, SizeMk__BackingField = 9, SizeWk__BackingField = 7, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete1.Nicknamek__BackingField, Statusk__BackingField = Constants.REQUESTED, ReceivedOnk__BackingField = new DateTime(2012, 8, 18, 11, 26, 13).ToShortDateString() };
            var inventoryItem2 = new InventoryItemDto() { ModelDtok__BackingField = model1, SizeMk__BackingField = 11, SizeWk__BackingField = 9, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete1.Nicknamek__BackingField, Statusk__BackingField = Constants.ORDERED, ReceivedOnk__BackingField = new DateTime(2012, 2, 16, 11, 4, 23).ToShortDateString() };
            var inventoryItem3 = new InventoryItemDto() { ModelDtok__BackingField = model1, SizeMk__BackingField = 12, SizeWk__BackingField = 10, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete1.Nicknamek__BackingField, Statusk__BackingField = Constants.IN_STOCK, ReceivedOnk__BackingField = new DateTime(2012, 11, 26, 8, 16, 22).ToShortDateString() };
            var inventoryItem4 = new InventoryItemDto() { ModelDtok__BackingField = model1, SizeMk__BackingField = 12, SizeWk__BackingField = 10, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete2.Nicknamek__BackingField, Statusk__BackingField = Constants.DISTRIBUTED, ReceivedOnk__BackingField = new DateTime(2012, 12, 28, 15, 3, 13).ToShortDateString() };
            var inventoryItem5 = new InventoryItemDto() { ModelDtok__BackingField = model1, SizeMk__BackingField = 9, SizeWk__BackingField = 7, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete2.Nicknamek__BackingField, Statusk__BackingField = Constants.SURPLUSED, ReceivedOnk__BackingField = new DateTime(2012, 1, 12, 22, 49, 55).ToShortDateString() };
            var inventoryItem6 = new InventoryItemDto() { ModelDtok__BackingField = model2, SizeMk__BackingField = 11, SizeWk__BackingField = 9, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete2.Nicknamek__BackingField, Statusk__BackingField = Constants.RETURNED, ReceivedOnk__BackingField = new DateTime(2012, 9, 18, 10, 59, 31).ToShortDateString() };
            var inventoryItem7 = new InventoryItemDto() { ModelDtok__BackingField = model2, SizeMk__BackingField = 9, SizeWk__BackingField = 7, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete3.Nicknamek__BackingField, Statusk__BackingField = Constants.RECALLED, ReceivedOnk__BackingField = new DateTime(2012, 5, 21, 21, 45, 33).ToShortDateString() };
            var inventoryItem8 = new InventoryItemDto() { ModelDtok__BackingField = model2, SizeMk__BackingField = 12, SizeWk__BackingField = 10, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete3.Nicknamek__BackingField, Statusk__BackingField = Constants.RECORDED_AS_LOST, ReceivedOnk__BackingField = new DateTime(2012, 1, 19, 2, 50, 54).ToShortDateString() };
            var inventoryItem9 = new InventoryItemDto() { ModelDtok__BackingField = model2, SizeMk__BackingField = 9, SizeWk__BackingField = 7, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete3.Nicknamek__BackingField, Statusk__BackingField = Constants.IN_STOCK, ReceivedOnk__BackingField = new DateTime(2012, 6, 3, 16, 58, 1).ToShortDateString() };

            athlete1.Inventoryk__BackingField.Add(inventoryItem1);
            athlete1.Inventoryk__BackingField.Add(inventoryItem2);
            athlete1.Inventoryk__BackingField.Add(inventoryItem3);
            athlete2.Inventoryk__BackingField.Add(inventoryItem4);
            athlete2.Inventoryk__BackingField.Add(inventoryItem5);
            athlete2.Inventoryk__BackingField.Add(inventoryItem6);
            athlete3.Inventoryk__BackingField.Add(inventoryItem7);
            athlete3.Inventoryk__BackingField.Add(inventoryItem8);
            athlete3.Inventoryk__BackingField.Add(inventoryItem9);

            _inventoryViewModel.MyAthletes = new ObservableCollection<AthleteDto>();
            _inventoryViewModel.MyAthletes.Add(athlete1);
            _inventoryViewModel.MyAthletes.Add(athlete2);
            _inventoryViewModel.MyAthletes.Add(athlete3);

            _inventoryViewModel.MyInventory.Add(inventoryItem1);
            _inventoryViewModel.MyInventory.Add(inventoryItem2);
            _inventoryViewModel.MyInventory.Add(inventoryItem3);
            _inventoryViewModel.MyInventory.Add(inventoryItem4);
            _inventoryViewModel.MyInventory.Add(inventoryItem5);
            _inventoryViewModel.MyInventory.Add(inventoryItem6);
            _inventoryViewModel.MyInventory.Add(inventoryItem7);
            _inventoryViewModel.MyInventory.Add(inventoryItem8);
            _inventoryViewModel.MyInventory.Add(inventoryItem9);

            _inventoryViewModel.ShowAllInventoryItems = true;
            _inventoryViewModel.ShowOnlyDefaultInventoryItems = false;
            Assert.AreEqual(9, _inventoryViewModel.MyInventory.Count);
            Assert.AreEqual(9, _inventoryViewModel.MyInventoryToShow.Count);

            Assert.AreEqual(3, _inventoryViewModel.FilterInventoryModel.Athletes.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Athletes.Contains(athlete1.Nicknamek__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Athletes.Contains(athlete2.Nicknamek__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Athletes.Contains(athlete3.Nicknamek__BackingField));

            Assert.AreEqual(8, _inventoryViewModel.FilterInventoryModel.Statuses.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.REQUESTED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.ORDERED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.IN_STOCK));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.DISTRIBUTED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.SURPLUSED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.RETURNED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.RECALLED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.RECORDED_AS_LOST));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.ModelNames.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ModelNames.Contains(model1.ModelNamek__BackingField));

            Assert.AreEqual(2, _inventoryViewModel.FilterInventoryModel.ModelNumbers.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ModelNumbers.Contains(model1.ModelNumberk__BackingField));

            Assert.AreEqual(3, _inventoryViewModel.FilterInventoryModel.SizeMs.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeMs.Contains("9"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeMs.Contains("11"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeMs.Contains("12"));

            Assert.AreEqual(3, _inventoryViewModel.FilterInventoryModel.SizeWs.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeWs.Contains("7"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeWs.Contains("9"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeWs.Contains("10"));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.Widths.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Widths.Contains("N"));

            Assert.AreEqual(9, _inventoryViewModel.FilterInventoryModel.ReceivedOns.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem1.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem2.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem3.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem4.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem5.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem6.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem7.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem8.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem9.ReceivedOnk__BackingField));

            _inventoryViewModel.FilterInventoryModel.SelectedAthlete = athlete1.Nicknamek__BackingField;
            _inventoryViewModel.FilterCommand.Execute(null);

            Assert.AreEqual(3, _inventoryViewModel.MyInventory.Count);

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.Athletes.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Athletes.Contains(athlete1.Nicknamek__BackingField));

            Assert.AreEqual(3, _inventoryViewModel.FilterInventoryModel.Statuses.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.REQUESTED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.ORDERED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.IN_STOCK));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.ModelNames.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ModelNames.Contains(model1.ModelNamek__BackingField));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.ModelNumbers.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ModelNumbers.Contains(model1.ModelNumberk__BackingField));

            Assert.AreEqual(3, _inventoryViewModel.FilterInventoryModel.SizeMs.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeMs.Contains("9"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeMs.Contains("11"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeMs.Contains("12"));

            Assert.AreEqual(3, _inventoryViewModel.FilterInventoryModel.SizeWs.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeWs.Contains("7"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeWs.Contains("9"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeWs.Contains("10"));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.Widths.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Widths.Contains("N"));

            _inventoryViewModel.FilterInventoryModel.SelectedStatus = Constants.REQUESTED;
            _inventoryViewModel.FilterCommand.Execute(null);

            Assert.AreEqual(1, _inventoryViewModel.MyInventory.Count);

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.Athletes.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Athletes.Contains(athlete1.Nicknamek__BackingField));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.Statuses.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.REQUESTED));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.ModelNames.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ModelNames.Contains(model1.ModelNamek__BackingField));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.ModelNumbers.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ModelNumbers.Contains(model1.ModelNumberk__BackingField));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.SizeMs.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeMs.Contains("9"));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.SizeWs.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeWs.Contains("7"));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.Widths.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Widths.Contains("N"));

            _inventoryViewModel.ClearFilterCommand.Execute(null);

            Assert.AreEqual(9, _inventoryViewModel.MyInventory.Count);
            Assert.AreEqual(9, _inventoryViewModel.MyInventoryToShow.Count);

            Assert.AreEqual(3, _inventoryViewModel.FilterInventoryModel.Athletes.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Athletes.Contains(athlete1.Nicknamek__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Athletes.Contains(athlete2.Nicknamek__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Athletes.Contains(athlete3.Nicknamek__BackingField));

            Assert.AreEqual(8, _inventoryViewModel.FilterInventoryModel.Statuses.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.REQUESTED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.ORDERED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.IN_STOCK));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.DISTRIBUTED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.SURPLUSED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.RETURNED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.RECALLED));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Statuses.Contains(Constants.RECORDED_AS_LOST));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.ModelNames.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ModelNames.Contains(model1.ModelNamek__BackingField));

            Assert.AreEqual(2, _inventoryViewModel.FilterInventoryModel.ModelNumbers.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ModelNumbers.Contains(model1.ModelNumberk__BackingField));

            Assert.AreEqual(3, _inventoryViewModel.FilterInventoryModel.SizeMs.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeMs.Contains("9"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeMs.Contains("11"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeMs.Contains("12"));

            Assert.AreEqual(3, _inventoryViewModel.FilterInventoryModel.SizeWs.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeWs.Contains("7"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeWs.Contains("9"));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.SizeWs.Contains("10"));

            Assert.AreEqual(1, _inventoryViewModel.FilterInventoryModel.Widths.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.Widths.Contains("N"));

            Assert.AreEqual(9, _inventoryViewModel.FilterInventoryModel.ReceivedOns.Count);
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem1.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem2.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem3.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem4.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem5.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem6.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem7.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem8.ReceivedOnk__BackingField));
            Assert.IsTrue(_inventoryViewModel.FilterInventoryModel.ReceivedOns.Contains(inventoryItem9.ReceivedOnk__BackingField));
        }
            protected override void Establish_context()
            {
                Mapper.CreateMap<Model, ModelDto>();
                Mapper.CreateMap<Item, ItemDto>();
                Mapper.CreateMap<SubItem, SubItemDto>();

                var model = new Model
                    {
                        Items = new List<Item>
                            {
                                new SubItem
                                    {
                                        Prop = "value1",
                                        SubProp = "value2"
                                    }
                            }
                    };
                _result = Mapper.Map<Model, ModelDto>(model);
            }
            protected override void Establish_context()
            {
                Mapper.AddFormatter<SampleFormatter>();
                Mapper.ForSourceType<int>().SkipFormatter<SampleFormatter>();

                Mapper.CreateMap<ModelObject, ModelDto>();

                var model = new ModelObject { ValueOne = 24 };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
            protected override void Establish_context()
            {
                Mapper
                    .CreateMap<ModelObject, ModelDto>()
                    .ForMember(dto => dto.ValueOne, opt => opt.FormatNullValueAs("I am null"));

                var model = new ModelObject { ValueOne = null };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
            protected override void Establish_context()
            {
                Mapper.ForSourceType<DateTime>().AddFormatter<ShortDateFormatter>();
                Mapper.ForSourceType<int>().AddFormatExpression(context => ((int)context.SourceValue + 1).ToString());

                Mapper.CreateMap<ModelObject, ModelDto>();

                var model = new ModelObject { StartDate = new DateTime(2004, 12, 25), OtherValue = 43 };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
            protected override void Establish_context()
            {
                Mapper.AddFormatter<CrazyEncoder>();

                Mapper.Reset();

                Mapper.CreateMap<ModelObject, ModelDto>();

                var modelObject = new ModelObject { Value = 14 };

                _modelDto = Mapper.Map<ModelObject, ModelDto>(modelObject);
            }
        private void SaveNewModel()
        {
            var newModel = new ModelDto();

            newModel.ModelNumberk__BackingField = newModelNumber;
            newModel.ModelNamek__BackingField = newModelName;
            newModel.Typek__BackingField = newModelType;
            newModel.Pricek__BackingField = newModelPrice;
            newModel.Colork__BackingField = newModelColor;
            newModel.IsDiscontinuedk__BackingField = false;

            newModel = _service.SaveModel(newModel);

            modelsAvailable.Add(newModel);
            ResetNewModelFields();
            RaisePropertyChanged("ModelsAvailable");
        }
        public void SavingInventoryItemSetsSerialNumberInInventoryLabelModel()
        {
            var athlete = new AthleteDto() { FirstNamek__BackingField = "John", LastNamek__BackingField = "Doe", Inventoryk__BackingField = new List<InventoryItemDto>() };
            var eventArea = new EventAreaDto() { EventNamek__BackingField = Constants.POLE_VAULT };
            var model = new ModelDto() { ModelNamek__BackingField = "Model name" };
            _inventoryViewModel.NewInventorySelectedAthlete = athlete;
            _inventoryViewModel.NewInventorySelectedEventArea = eventArea;
            _inventoryViewModel.NewInventorySelectedModel = model;
            _inventoryViewModel.NewInventoryItemSize = 14;
            _inventoryViewModel.NewInventorySelectedSizeIsM = true;
            _inventoryViewModel.NewInventorySelectedSizeIsW = false;
            _inventoryViewModel.NewInventoryItemWidth = "N";
            var inventoryItemDto = new InventoryItemDto() { SerialNumberk__BackingField = 123456 };
            _mockAppService.Setup(x => x.SaveInventoryItem(It.IsAny<InventoryItemDto>())).Returns(inventoryItemDto);

            _inventoryViewModel.SaveNewInventoryCommand.Execute(null);

            Assert.AreEqual(inventoryItemDto.SerialNumberk__BackingField.ToString(), _inventoryViewModel.InventoryLabelModel.SerialNumber);
        }
        public InventoryViewModel(IApplicationService service, ILabelPrinter labelPrinter)
        {
            this._service = service;
            this._labelPrinter = labelPrinter;

            myInventory = new ObservableCollection<InventoryItemDto>();
            myInventoryBackup = new ObservableCollection<InventoryItemDto>();
            movementTypes = new ObservableCollection<String>(Constants.MOVEMENT_TYPES);
            modelsAvailable = new ObservableCollection<ModelDto>(GetModelsAvailable());

            totalsByStatusModel = new TotalByStatusModel();
            filterInventoryModel = new FilterInventoryModel();
            inventoryLabelModel = new InventoryLabelModel();

            showAllInventoryItems = false;
            showOnlyDefaultInventoryItems = true;
            isAdmin = userDto == null ? false : userDto.IsAdmin;
            newInventorySelectedSizeIsM = true;
            newInventorySelectedSizeIsW = false;

            myInventoryIsVisible = VISIBLE;
            newItemEntryIsVisible = HIDDEN;

            newInventoryAthleteIndex = -1;

            newInventorySelectedAthlete = new AthleteDto();
            newInventorySelectedModel = new ModelDto();

            ProcessMovementCommand = new RelayCommand(ProcessInventoryMovement);
            FilterCommand = new RelayCommand(FilterInventory);
            ClearFilterCommand = new RelayCommand(ResetMyInventory);
            ShowNewInventoryEntryCommand = new RelayCommand(ShowNewInventoryEntry);
            SaveNewInventoryCommand = new RelayCommand(SaveNewInventoryItem);
            ShowMyInventoryCommand = new RelayCommand(ShowMyInventory);
            ClearInventoryItemEntryFieldsCommand = new RelayCommand(ResetNewInventoryEntryFields);
            SaveNewModelCommand = new RelayCommand(SaveNewModel);
            ClearNewModelFields = new RelayCommand(ResetNewModelFields);
            DistributeItemCommand = new RelayCommand<InventoryItemDto>(itemToDistribute => DistributeItem(itemToDistribute));
            ReturnItemToVendorCommand = new RelayCommand<InventoryItemDto>(itemToDistribute => DistributeItem(itemToDistribute));
            ReturnToStockCommand = new RelayCommand<InventoryItemDto>(itemToDistribute => DistributeItem(itemToDistribute));
            SurplusItemCommand = new RelayCommand<InventoryItemDto>(itemToDistribute => DistributeItem(itemToDistribute));
            RecallItemCommand = new RelayCommand<InventoryItemDto>(itemToDistribute => DistributeItem(itemToDistribute));
            RecordItemAsLostCommand = new RelayCommand<InventoryItemDto>(itemToDistribute => DistributeItem(itemToDistribute));
            PrintInventoryLabelCommand = new RelayCommand<InventoryItemDto>(itemToPrint => PrintInventoryLabel(itemToPrint));
            AssignInventoryItemToAnotherAthleteCommand = new RelayCommand<InventoryItemDto>(itemToReassign => AssignInventoryItemToAnotherAthlete(itemToReassign));
            ShowInventoryItemHistoryCommand = new RelayCommand<InventoryItemDto>(itemWithHistory => ShowInventoryItemHistory(itemWithHistory));

            Messenger.Default.Register<UserDto>(
                this,
                (u) => UpdateUser(u)
            );

            Messenger.Default.Register<ObservableCollection<AthleteDto>>(
                this,
                (a) => MyAthletes = a
            );
        }
        public void ProcessingMovementDoesNotResetInventoryFilters()
        {
            var athlete1 = new AthleteDto() { FirstNamek__BackingField = "Jeff", LastNamek__BackingField = "Artis-Gray", Nicknamek__BackingField = "JArtis-Gray", Genderk__BackingField = 'M', TrainerSizeMk__BackingField = 14, TrainerSizeWk__BackingField = 12, SpikeSizeMk__BackingField = 14, SpikeSizeWk__BackingField = 12, Notesk__BackingField = "Notes about Jeff Artis-Gray", Statusk__BackingField = "Future", Inventoryk__BackingField = new List<InventoryItemDto>() };
            var athlete2 = new AthleteDto() { FirstNamek__BackingField = "Darren", LastNamek__BackingField = "Barlow", Nicknamek__BackingField = "DBarlow", Genderk__BackingField = 'M', TrainerSizeMk__BackingField = 14, TrainerSizeWk__BackingField = 12, SpikeSizeMk__BackingField = 14, SpikeSizeWk__BackingField = 12, Notesk__BackingField = "Notes about Darren Barlow", Statusk__BackingField = "Past", Inventoryk__BackingField = new List<InventoryItemDto>() };
            var athlete3 = new AthleteDto() { FirstNamek__BackingField = "Jared", LastNamek__BackingField = "Berman", Nicknamek__BackingField = "JBerman", Genderk__BackingField = 'M', TrainerSizeMk__BackingField = 13, TrainerSizeWk__BackingField = 11, SpikeSizeMk__BackingField = 13, SpikeSizeWk__BackingField = 11, Notesk__BackingField = "Notes about Jared Berman", Statusk__BackingField = "Past", Inventoryk__BackingField = new List<InventoryItemDto>() };

            var model1 = new ModelDto() { ModelNumberk__BackingField = "524395-386", ModelNamek__BackingField = "Air Pegasus+ 29 Trail", Typek__BackingField = "Running", Pricek__BackingField = 105, Colork__BackingField = "Silver Sage/Team Red/University Red/Total Orange", IsDiscontinuedk__BackingField = false };
            var model2 = new ModelDto() { ModelNumberk__BackingField = "524395-038", ModelNamek__BackingField = "Air Pegasus+ 29 Trail", Typek__BackingField = "Running", Pricek__BackingField = 105, Colork__BackingField = "Cool Grey/Total Orange/Signal Blue/Electric Green", IsDiscontinuedk__BackingField = false };

            var inventoryItem1 = new InventoryItemDto() { ModelDtok__BackingField = model1, SizeMk__BackingField = 9, SizeWk__BackingField = 7, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete1.Nicknamek__BackingField, Statusk__BackingField = Constants.REQUESTED, ReceivedOnk__BackingField = new DateTime(2012, 8, 18, 11, 26, 13).ToShortDateString() };
            var inventoryItem2 = new InventoryItemDto() { ModelDtok__BackingField = model1, SizeMk__BackingField = 11, SizeWk__BackingField = 9, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete1.Nicknamek__BackingField, Statusk__BackingField = Constants.ORDERED, ReceivedOnk__BackingField = new DateTime(2012, 2, 16, 11, 4, 23).ToShortDateString() };
            var inventoryItem3 = new InventoryItemDto() { ModelDtok__BackingField = model1, SizeMk__BackingField = 12, SizeWk__BackingField = 10, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete1.Nicknamek__BackingField, Statusk__BackingField = Constants.IN_STOCK, ReceivedOnk__BackingField = new DateTime(2012, 11, 26, 8, 16, 22).ToShortDateString() };
            var inventoryItem4 = new InventoryItemDto() { ModelDtok__BackingField = model1, SizeMk__BackingField = 12, SizeWk__BackingField = 10, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete2.Nicknamek__BackingField, Statusk__BackingField = Constants.DISTRIBUTED, ReceivedOnk__BackingField = new DateTime(2012, 12, 28, 15, 3, 13).ToShortDateString() };
            var inventoryItem5 = new InventoryItemDto() { ModelDtok__BackingField = model1, SizeMk__BackingField = 9, SizeWk__BackingField = 7, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete2.Nicknamek__BackingField, Statusk__BackingField = Constants.SURPLUSED, ReceivedOnk__BackingField = new DateTime(2012, 1, 12, 22, 49, 55).ToShortDateString() };
            var inventoryItem6 = new InventoryItemDto() { ModelDtok__BackingField = model2, SizeMk__BackingField = 11, SizeWk__BackingField = 9, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete2.Nicknamek__BackingField, Statusk__BackingField = Constants.RETURNED, ReceivedOnk__BackingField = new DateTime(2012, 9, 18, 10, 59, 31).ToShortDateString() };
            var inventoryItem7 = new InventoryItemDto() { ModelDtok__BackingField = model2, SizeMk__BackingField = 9, SizeWk__BackingField = 7, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete3.Nicknamek__BackingField, Statusk__BackingField = Constants.RECALLED, ReceivedOnk__BackingField = new DateTime(2012, 5, 21, 21, 45, 33).ToShortDateString() };
            var inventoryItem8 = new InventoryItemDto() { ModelDtok__BackingField = model2, SizeMk__BackingField = 12, SizeWk__BackingField = 10, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete3.Nicknamek__BackingField, Statusk__BackingField = Constants.RECORDED_AS_LOST, ReceivedOnk__BackingField = new DateTime(2012, 1, 19, 2, 50, 54).ToShortDateString() };
            var inventoryItem9 = new InventoryItemDto() { ModelDtok__BackingField = model2, SizeMk__BackingField = 9, SizeWk__BackingField = 7, Widthk__BackingField = "N", AthleteNicknamek__BackingField = athlete3.Nicknamek__BackingField, Statusk__BackingField = Constants.IN_STOCK, ReceivedOnk__BackingField = new DateTime(2012, 6, 3, 16, 58, 1).ToShortDateString() };

            athlete1.Inventoryk__BackingField.Add(inventoryItem1);
            athlete1.Inventoryk__BackingField.Add(inventoryItem2);
            athlete1.Inventoryk__BackingField.Add(inventoryItem3);
            athlete2.Inventoryk__BackingField.Add(inventoryItem4);
            athlete2.Inventoryk__BackingField.Add(inventoryItem5);
            athlete2.Inventoryk__BackingField.Add(inventoryItem6);
            athlete3.Inventoryk__BackingField.Add(inventoryItem7);
            athlete3.Inventoryk__BackingField.Add(inventoryItem8);
            athlete3.Inventoryk__BackingField.Add(inventoryItem9);

            _inventoryViewModel.MyAthletes = new ObservableCollection<AthleteDto>();
            _inventoryViewModel.MyAthletes.Add(athlete1);
            _inventoryViewModel.MyAthletes.Add(athlete2);
            _inventoryViewModel.MyAthletes.Add(athlete3);

            _inventoryViewModel.MyInventory.Add(inventoryItem1);
            _inventoryViewModel.MyInventory.Add(inventoryItem2);
            _inventoryViewModel.MyInventory.Add(inventoryItem3);
            _inventoryViewModel.MyInventory.Add(inventoryItem4);
            _inventoryViewModel.MyInventory.Add(inventoryItem5);
            _inventoryViewModel.MyInventory.Add(inventoryItem6);
            _inventoryViewModel.MyInventory.Add(inventoryItem7);
            _inventoryViewModel.MyInventory.Add(inventoryItem8);
            _inventoryViewModel.MyInventory.Add(inventoryItem9);

            _inventoryViewModel.ShowAllInventoryItems = true;
            _inventoryViewModel.ShowOnlyDefaultInventoryItems = false;

            _inventoryViewModel.FilterInventoryModel.SelectedAthlete = _inventoryViewModel.MyAthletes[0].Nicknamek__BackingField;

            _inventoryViewModel.FilterCommand.Execute(null);

            Assert.AreEqual(3, _inventoryViewModel.MyInventory.Count);

            _inventoryViewModel.SerialNumber = _inventoryViewModel.MyAthletes[0].Inventoryk__BackingField[0].SerialNumberk__BackingField;
            _inventoryViewModel.SelectedMovementType = Constants.DISTRIBUTE;

            inventoryItem1.Statusk__BackingField = Constants.DISTRIBUTED;
            _mockAppService.Setup(x => x.Distribute(It.IsAny<InventoryItemDto>(), It.IsAny<String>())).Returns(inventoryItem1);

            _inventoryViewModel.ProcessMovementCommand.Execute(null);

            Assert.AreEqual(3, _inventoryViewModel.MyInventory.Count);
        }
        public void SizeWsListIsSortedNaturallyByDoubleValue()
        {
            var model = new ModelDto();
            _inventoryViewModel.MyInventory = new ObservableCollection<InventoryItemDto>()
            {
                new InventoryItemDto() { ModelDtok__BackingField = model, SizeMk__BackingField = 9, SizeWk__BackingField = 11 },
                new InventoryItemDto() { ModelDtok__BackingField = model, SizeMk__BackingField = 7, SizeWk__BackingField = 9 },
                new InventoryItemDto() { ModelDtok__BackingField = model, SizeMk__BackingField = 14, SizeWk__BackingField = 16 },
                new InventoryItemDto() { ModelDtok__BackingField = model, SizeMk__BackingField = 8, SizeWk__BackingField = 10 },
                new InventoryItemDto() { ModelDtok__BackingField = model, SizeMk__BackingField = 8, SizeWk__BackingField = 10 },
                new InventoryItemDto() { ModelDtok__BackingField = model, SizeMk__BackingField = 10, SizeWk__BackingField = 12 },
                new InventoryItemDto() { ModelDtok__BackingField = model, SizeMk__BackingField = 6, SizeWk__BackingField = 8 },
                new InventoryItemDto() { ModelDtok__BackingField = model, SizeMk__BackingField = 9, SizeWk__BackingField = 11 },
            };

            Assert.AreEqual("8", _inventoryViewModel.FilterInventoryModel.SizeWs[0]);
            Assert.AreEqual("9", _inventoryViewModel.FilterInventoryModel.SizeWs[1]);
            Assert.AreEqual("10", _inventoryViewModel.FilterInventoryModel.SizeWs[2]);
            Assert.AreEqual("11", _inventoryViewModel.FilterInventoryModel.SizeWs[3]);
            Assert.AreEqual("12", _inventoryViewModel.FilterInventoryModel.SizeWs[4]);
            Assert.AreEqual("16", _inventoryViewModel.FilterInventoryModel.SizeWs[5]);
        }
Beispiel #45
0
            protected override void Establish_context()
            {
                var model = new ModelObject();

                Mapper.CreateMap<ModelObject, ModelDto>();

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
Beispiel #46
0
            protected override void Establish_context()
            {
                Mapper.CreateMap<ModelObject, ModelDto>();

                _model = new ModelObject { SomeValue = 2 };
                _dto = Mapper.Map<ModelObject, ModelDto>(_model);
            }
        public void SavingInventoryItemClearsSelectedItemsFields()
        {
            var athlete = new AthleteDto() { FirstNamek__BackingField = "John", LastNamek__BackingField = "Doe", Inventoryk__BackingField = new List<InventoryItemDto>() };
            _inventoryViewModel.MyAthletes = new ObservableCollection<AthleteDto>();
            _inventoryViewModel.MyAthletes.Add(athlete);
            var eventArea = new EventAreaDto() { EventNamek__BackingField = Constants.POLE_VAULT };
            var model = new ModelDto() { ModelNamek__BackingField = "Model name" };
            _inventoryViewModel.NewInventorySelectedAthlete = athlete;
            _inventoryViewModel.NewInventorySelectedEventArea = eventArea;
            _inventoryViewModel.NewInventorySelectedModel = model;
            _inventoryViewModel.NewInventoryItemSize = 14;
            _inventoryViewModel.NewInventorySelectedSizeIsM = true;
            _inventoryViewModel.NewInventorySelectedSizeIsW = false;
            _inventoryViewModel.NewInventoryItemWidth = "N";
            var inventoryItemDto = new InventoryItemDto() { SerialNumberk__BackingField = 123456, Statusk__BackingField = Constants.IN_STOCK };
            _mockAppService.Setup(x => x.SaveInventoryItem(It.IsAny<InventoryItemDto>())).Returns(inventoryItemDto);

            _inventoryViewModel.SaveNewInventoryCommand.Execute(null);

            Assert.AreEqual(null, _inventoryViewModel.NewInventorySelectedAthlete);
            Assert.AreEqual(null, _inventoryViewModel.NewInventorySelectedEventArea);
            Assert.AreEqual(null, _inventoryViewModel.NewInventorySelectedModel);
            Assert.AreEqual(null, _inventoryViewModel.NewInventoryItemSize);
            Assert.AreEqual(true, _inventoryViewModel.NewInventorySelectedSizeIsM);
            Assert.AreEqual(false, _inventoryViewModel.NewInventorySelectedSizeIsW);
            Assert.AreEqual(String.Empty, _inventoryViewModel.NewInventoryItemWidth);
            Assert.AreEqual(-1, _inventoryViewModel.NewInventoryAthleteIndex);
        }
Beispiel #48
0
 protected override void Because_of()
 {
     var model = new ModelObject();
     _result = Mapper.Map<ModelObject, ModelDto>(model);
 }
        public void SaveNewModelCommand()
        {
            _inventoryViewModel.NewModelNumber = "asdfad";
            _inventoryViewModel.NewModelName = "dfadsfa";
            _inventoryViewModel.SelectedNewModelType = "asdfadf";
            _inventoryViewModel.NewModelPrice = 105;
            _inventoryViewModel.NewModelColor = "asdfad";

            var returnedModel = new ModelDto();
            _mockAppService.Setup(x => x.SaveModel(It.IsAny<ModelDto>())).Returns(returnedModel);

            _inventoryViewModel.SaveNewModelCommand.Execute(null);

            NewModelFieldsAreReset();
            Assert.AreEqual(1, _inventoryViewModel.ModelsAvailable.Count);
            _mockAppService.VerifyAll();
        }
Beispiel #50
0
 protected override void Because_of()
 {
     _model = new ModelObject();
     _dto = Mapper.Map<ModelObject, ModelDto>(_model);
 }
            protected override void Establish_context()
            {
                Mapper.AddFormatExpression(context => string.Format("{0} Value", context.SourceValue));
                Mapper.ForSourceType<int>().AddFormatExpression(context => ((int)context.SourceValue + 1).ToString());

                Mapper.CreateMap<ModelObject, ModelDto>();

                var model = new ModelObject { OtherValue = 43 };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
Beispiel #52
0
 public void Should_always_provide_a_dto()
 {
     _result = Mapper.Map<ModelObject, ModelDto>(null);
     _result.ShouldNotBeNull();
 }
            protected override void Establish_context()
            {
                Mapper.ForSourceType<int>().AddFormatter<SampleFormatter>();

                Mapper
                    .CreateMap<ModelObject, ModelDto>()
                    .ForMember(d => d.ValueTwo, opt => opt.SkipFormatter<SampleFormatter>());

                var model = new ModelObject { ValueOne = 24, ValueTwo = 42 };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
Beispiel #54
0
 protected override void Because_of()
 {
     var model = new ModelObject
     {
         SomeValue = "Some value"
     };
     _result = Mapper.Map<ModelObject, ModelDto>(model);
 }
            protected override void Establish_context()
            {
                Mapper
                    .CreateMap<ModelObject, ModelDto>()
                    .ForMember(dto => dto.ValueOne, opt => opt.AddFormatter<SampleFormatter>());

                var model = new ModelObject { ValueOne = 24 };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
            protected override void Establish_context()
            {
                Mapper.Reset();

                var model = new ModelObject
                {
                    BaseDate = new DateTime(2007, 4, 5),
                    Sub = new ModelSubObject
                    {
                        ProperName = "Some name",
                        SubSub = new ModelSubSubObject
                        {
                            IAmACoolProperty = "Cool daddy-o"
                        }
                    },
                    Sub2 = new ModelSubObject
                    {
                        ProperName = "Sub 2 name"
                    },
                    SubWithExtraName = new ModelSubObject
                    {
                        ProperName = "Some other name"
                    },
                    SubMissing = new ModelSubObject
                    {
                        ProperName = "I have a missing sub sub object"
                    }
                };

                Mapper.CreateMap<ModelObject, ModelDto>();
                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }
        public void NewInventoryItemFieldsSetLabelValuesCorrectly()
        {
            var athlete = new AthleteDto() { FirstNamek__BackingField = "John", LastNamek__BackingField = "Doe" };
            var eventArea = new EventAreaDto() { EventNamek__BackingField = Constants.POLE_VAULT };
            var model = new ModelDto() { ModelNamek__BackingField = "Model name" };
            _inventoryViewModel.NewInventorySelectedAthlete = athlete;
            _inventoryViewModel.NewInventorySelectedEventArea = eventArea;
            _inventoryViewModel.NewInventorySelectedModel = model;
            _inventoryViewModel.NewInventoryItemSize = 14;
            _inventoryViewModel.NewInventorySelectedSizeIsM = true;
            _inventoryViewModel.NewInventorySelectedSizeIsW = false;
            _inventoryViewModel.NewInventoryItemWidth = "N";

            Assert.AreEqual(athlete.FirstNamek__BackingField + " " + athlete.LastNamek__BackingField, _inventoryViewModel.InventoryLabelModel.AthleteFirstAndLastName);
            Assert.AreEqual("PV", _inventoryViewModel.InventoryLabelModel.EventAreaAbbreviation);
            Assert.AreEqual("M", _inventoryViewModel.InventoryLabelModel.SizingGender);
            Assert.AreEqual(_inventoryViewModel.NewInventoryItemSize, _inventoryViewModel.InventoryLabelModel.Size);
            Assert.AreEqual("n/a", _inventoryViewModel.InventoryLabelModel.SerialNumber);
            Assert.AreEqual(DateTime.Now.ToString("MMM"), _inventoryViewModel.InventoryLabelModel.ReceivedMonth);
            Assert.AreEqual(DateTime.Now.Year.ToString(), _inventoryViewModel.InventoryLabelModel.ReceivedYear);
            Assert.AreEqual(_inventoryViewModel.NewInventorySelectedModel.ModelNamek__BackingField, _inventoryViewModel.InventoryLabelModel.ModelName);
        }
Beispiel #58
0
            protected override void Establish_context()
            {
                Mapper.CreateMap<ModelObject, ModelDto>();

                var model = new ModelObject
                {
                    SomeValue = "Some value"
                };

                _result = Mapper.Map<ModelObject, ModelDto>(model);
            }