public async Task <IActionResult> Add(EquipmentToAdd equipment) { var reply = await _client.AddEquipmentAsync(equipment); if (reply.Code == 200) { return(RedirectToAction("List")); } else { ViewBag.Message = String.Format(reply.Message); return(View()); } }
public async Task AddNewEquipment() { EquipmentToAdd newEquipment = new EquipmentToAdd { Name = "Nowy Sprzęt Testowy", SerialNumber = _uniqSerialNumber, Type = EquipmentType.Agd }; await _client.AddEquipmentAsync(newEquipment); var warehouseAfterAdd = _client.GetAllEquipments(_equipmentsRequest); int warehouseBeforeSize = _warehouseBeforeAdd.EquipmentList.Count; int warehouseAfterSize = warehouseAfterAdd.EquipmentList.Count; Assert.AreEqual(1, warehouseAfterSize - warehouseBeforeSize); }
public async Task AddEquipmentWithToLongSerialNumber() { EquipmentToAdd errorEquipment = new EquipmentToAdd { Name = "Nowy Sprzęt Testowy", SerialNumber = findUniqSerialNumber(_warehouseBeforeAdd.EquipmentList, 12), Type = EquipmentType.Agd }; await _client.AddEquipmentAsync(errorEquipment); var warehouseAfterAdd = _client.GetAllEquipments(_equipmentsRequest); int warehouseBeforeSize = _warehouseBeforeAdd.EquipmentList.Count; int warehouseAfterSize = warehouseAfterAdd.EquipmentList.Count; Assert.AreEqual(0, warehouseAfterSize - warehouseBeforeSize); }
public override async Task <Confirmation> AddEquipment(EquipmentToAdd request, ServerCallContext context) { Equipment equipment = _mapper.Map <Equipment>(request); var precipitate = await _validator.ValidateAsync(equipment); if (precipitate.IsValid) { return(await _repo.AddEquipment(equipment)); } else { return new Confirmation() { Code = 404, Message = precipitate.ToString() } }; }