public EquipmentViewModel AddEquipment(EquipmentViewModel equipment) { var equipmentToAdd = EquipmentMapper.MapModelToEntity(equipment); equipmentToAdd.CreatedBy = "TEST"; equipmentToAdd.SeedData = false; var addedEquipment = _equipmentRepository.Add(equipmentToAdd); return(EquipmentMapper.MapEntityToModel(addedEquipment)); }
private EquipmentWrapper CreateNewEquipment() //calls the add method in the repository to insert new equipment and return it { var equipment = new EquipmentWrapper(new Model.Equipment()); //when property in equipment changes, and it has errors, disable the create button equipment.PropertyChanged += (s, e) => { if (e.PropertyName == nameof(Equipment.HasErrors)) { ((DelegateCommand)CreateEquipmentCommand).RaiseCanExecuteChanged(); } }; ((DelegateCommand)CreateEquipmentCommand).RaiseCanExecuteChanged(); //default values equipment.EquipmentSerialnumber = ""; equipment.EquipmentStatus = false; equipment.EquipmentDateCreated = DateTime.Now; equipment.EquipmentCategoryId = 1; equipment.EquipmentConfigurationID = 1; equipment.EquipmentTypeID = 1; _equipmentRepository.Add(equipment.Model); //context is aware of the equipment to add return(equipment); }
public async Task <ApiResult <Equipment> > PostAsync(Equipment model) { _logger.LogInformation(_localizer["LogMethodCalled", "api/Equipment/Post"]); ApiResult <Equipment> response = await _equipmentRepository.Add(model); _logger.LogInformation(_localizer["LogMethodResult", "api/Equipment/Post", response.Deserialize()]); return(response); }
public bool Add(Equipment item) { if (!_equipmentRepository.Exists(m => m.OperatorRootID.Trim().ToUpper() == item.OperatorRootID.ToUpper() && m.Name.Trim().ToUpper() == item.Name.ToUpper() && m.Band.Trim().ToUpper() == item.Band.ToUpper() && m.Tx == item.Tx)) { item.CreatedDate = DateTime.Now; _equipmentRepository.Add(item); } return(true); }
private void OnAddExecute() { var wrapper = new EquipmentWrapper(new Equipment()); wrapper.PropertyChanged += Wrapper_PropertyChanged; _equipmentRepository.Add(wrapper.Model); Equipments.Add(wrapper); //trigger the validation wrapper.Name = ""; }
public IHttpActionResult Post([FromBody] Equipment equipment) { var result = new Equipment(); if (ModelState.IsValid) { result = equipmentRepository.Add(equipment); } return(Json(result)); }
public async Task <int> Handle(CreateEquipmentCommand request, CancellationToken cancellationToken) { var equipment = new Equipment(request.Name, request.Number); _logger.LogInformation("----- Creating Equipment - Equipment: {@equipment}", equipment); _equipmentRepository.Add(equipment); await _equipmentRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken); return(equipment.Id); }
public void TestAdd() { var equipment = new Equipment { SerialNumber = 1, Name = "equipment1", NextControlDate = new DateTime() }; _repo.Add(equipment); _mockSet.Verify(m => m.Add(It.IsAny <Equipment>()), Times.Once()); }
/// <summary> /// The Save /// </summary> /// <param name="entity">The entity<see cref="Equipment"/></param> /// <returns>The <see cref="ServiceResult"/></returns> public ServiceResult Save(Equipment entity) { try { if (entity.Identifier == 0) { _repository.Add(entity); } else { _repository.Update(entity); } return(new ServiceResult(true)); } catch (Exception ex) { return(new ServiceResult(false) { Error = ex.ToString() }); } }
public async Task <IActionResult> CreateNew(Equipment equip) { equip.EquipmentId = util.RandomString(8); Equipment check; do { check = null; check = equipment.Get(equip.EquipmentId); }while (check != null); equip.EquipmentSercurityCode = util.RandomString(10); equip.CreateDate = DateTime.Now; equip.Username = HttpContext.Session.GetString("adminName"); equipment.Add(equip); await equipmentGroup.SaveChangesAsync(); if (equip.Type == 2) { string url = "https://feedbackwebqr.azurewebsites.net/" + "Home/GetFeedback?equipmentId=" + equip.EquipmentId; return(RedirectToAction("ShowQR", new { qrText = url })); } return(RedirectToAction("ShowAll")); }
public async Task AddAndSave(Equipment equipment) { _equipmentRepo.Add(equipment); await _equipmentRepo.Save(); }