public async Task <Response> Update(ParkingSpotDTO pakingSpot) { Response response = new Response(); ParkingSpotValidator validate = new ParkingSpotValidator(); ValidationResult result = validate.Validate(pakingSpot); if (!result.IsValid) { foreach (var failure in result.Errors) { response.Errors.Add("Property " + failure.PropertyName + " failed validation. Error was: " + "(" + failure.ErrorMessage + ")"); } return(response); } else { try { return(response = await _iParkingSpotRepository.Update(pakingSpot)); } catch (Exception ex) { _log.Error(ex + "\nStackTrace: " + ex.StackTrace); response.Errors.Add("DataBase error, contact the system owner"); return(response); } } }
public async Task <Response> Insert(ParkingSpotDTO pakingSpot) { Response response = new Response(); ParkingSpotValidator validate = new ParkingSpotValidator(); ValidationResult result = validate.Validate(pakingSpot); if (!result.IsValid) { foreach (var failure in result.Errors) { response.Errors.Add("Property " + failure.PropertyName + " failed validation. Error was: " + "(" + failure.ErrorMessage + ")"); } return(response); } else { return(await _iParkingSpotRepository.Insert(pakingSpot)); } }