コード例 #1
0
        public void EquipmentTypeManager_GetEquipmentTypes()
        {
            EquipmentTypeAccessor.Arrange(x => x.GetEquipmentTypes())
            .Returns(Task.FromResult(new List <EquipmentType>().AsEnumerable()))
            .OccursOnce();

            var res = manager.GetEquipmentTypes().Result;

            EquipmentTypeAccessor.Assert();
            Assert.IsNotNull(res);
            Assert.AreEqual(typeof(List <EquipmentType>), res.GetType());
        }
コード例 #2
0
        public async Task <ActionResult> AddEquipmentType(string name)
        {
            var errors = new List <string>();

            if (string.IsNullOrWhiteSpace(name))
            {
                errors.Add("Type name cannot be left empty.");
            }
            else if (this.ModelState.IsValid)
            {
                // implement save type
                var equipmentType = new EquipmentType
                {
                    Name = name
                };

                await EquipmentTypeManager.SaveEquipmentType(equipmentType);
            }

            var model = new ManageEquipmentTypesViewModel();

            model.EquipmentTypes = await EquipmentTypeManager.GetEquipmentTypes();

            return(View("ManageEquipmentTypes", model));
        }
コード例 #3
0
        public async Task <ActionResult> AddorEditEquipment(long?equipmentId)
        {
            var model     = new AddOrEditEquipmentViewModel();
            var equipment = new Equipment();

            if (equipmentId != null)
            {
                equipment = await EquipmentManager.GetEquipment((long)equipmentId);

                model.Title = "Edit Equipment";
            }
            else
            {
                equipment.DateAquired = DateTime.Now;
                model.Title           = "Add Equipment";
            }

            model.Equipment      = equipment;
            model.EquipmentTypes = await EquipmentTypeManager.GetEquipmentTypes();

            model.SelectTypes = model.EquipmentTypes.Select(x => new SelectListItem {
                Value    = x.EquipmentTypeId.ToString(),
                Text     = x.Name,
                Selected = model.Equipment.EquipmentTypeId == x.EquipmentTypeId ? true : false
            });
            model.SelectedID = equipment.EquipmentTypeId;
            return(View("AddOrEditEquipment", model));
        }
コード例 #4
0
        public async Task <ActionResult> ManageEquipmentTypes()
        {
            var model = new ManageEquipmentTypesViewModel();

            model.EquipmentTypes = await EquipmentTypeManager.GetEquipmentTypes();

            return(View(model));
        }
コード例 #5
0
        // end of stuff to look at

        public async Task <ActionResult> AddEquipment()
        {
            var model = new AddEquipmentModel();

            model.EquipmentTypes = await EquipmentTypeManager.GetEquipmentTypes();

            model.OptionList = from m in model.EquipmentTypes select new SelectListItem {
                Text = m.Name, Value = m.EquipmentTypeId.ToString()
            };
            return(View(model));
        }