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()); }
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)); }
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)); }
public async Task <ActionResult> ManageEquipmentTypes() { var model = new ManageEquipmentTypesViewModel(); model.EquipmentTypes = await EquipmentTypeManager.GetEquipmentTypes(); return(View(model)); }
// 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)); }