public async Task <IActionResult> Put(TechnicalServiceDto technicalService) { var _technicalService = await _technicalServiceRepository.GetById(technicalService.Id); if (_technicalService != null) { await _technicalServiceRepository.Update(technicalService); return(Ok(technicalService)); } else { return(Ok("El Reporte de Servicio Técnico no existe")); } }
public async Task Create(TechnicalServiceDto dto) { var _user = await _userRepository.GetById(dto.UserId); if (_user == null) { throw new Exception("El Usuario ingresado no existe"); } var _p = await _productRepairRepository.GetAll(); if (_p.FirstOrDefault(x => x.Code == dto.ProductRepairCode) != null) { throw new Exception("El producto ya fue cargado"); } await _productRepairRepository.Create(new ProductRepair() { CategoryId = dto.ProductRepairCategoryId, BrandId = dto.ProductRepairBrandId, Description = dto.ProductRepairDescription, Code = dto.ProductRepairCode }); var _prod = await _productRepairRepository.GetAll(null, null, false); var prod = _prod.FirstOrDefault(x => x.Code == dto.ProductRepairCode); //System.Console.WriteLine(_productId); var newTechnicalService = new TechnicalService() { SerialNumber = dto.SerialNumber, Observations = dto.Observations, AccessoriesReceived = dto.AccessoriesReceived, EquipmentFailure = dto.EquipmentFailure, DateReceived = dto.DateReceived, ServiceStatus = dto.ServiceStatus, DateStatus = dto.DateStatus, UserId = _user.Id, TotalInputs = dto.TotalInputs, //total insumos TotalLabor = dto.TotalLabor, //mano de obra Total = dto.Total, Diagnostic = dto.Diagnostic, IsDeleted = false, ProductRepairId = prod.Id }; await _technicalServiceRepository.Create(newTechnicalService); }
public async Task Update(TechnicalServiceDto dto) { var _t = await _technicalServiceRepository.GetById(dto.Id); _t.Observations = dto.Observations; _t.EquipmentFailure = dto.EquipmentFailure; _t.ServiceStatus = dto.ServiceStatus; _t.DateStatus = dto.DateStatus; _t.TotalInputs = dto.TotalInputs; //total insumos _t.TotalLabor = dto.TotalLabor; //mano de obra _t.Total = dto.Total; _t.Diagnostic = dto.Diagnostic; await _technicalServiceRepository.Update(_t); }
public async Task <IActionResult> Create(TechnicalServiceDto technicalService) { if (technicalService == null) { return(BadRequest()); } var _technicalService = _technicalServiceRepository.GetAll() .Result.FirstOrDefault(x => x.SerialNumber == technicalService.SerialNumber);//aca no se como hacer if (_technicalService != null) { ModelState.AddModelError("DateReceived", $"La Producto para Reparacion que ingreso el {_technicalService.DateReceived.ToShortDateString()}\n todavia no fué retirado"); return(BadRequest(ModelState)); } await _technicalServiceRepository.Create(technicalService); return(Ok(technicalService)); }
public async Task Delete(TechnicalServiceDto dto) { var e = await _technicalServiceRepository.GetById(dto.Id); await _technicalServiceRepository.Delete(e); }