public async Task <IActionResult> Create([FromBody] AppointmentCreateView appointmentBody) { try { await _save.Execute(EntityBuilder.Call <Appointment>(appointmentBody)); return(StatusCode(201)); } catch (NotFoundRegisterException err) { return(StatusCode(404, new { Message = err.Message })); }catch (CarNotAvalabityException err) { return(StatusCode(401, new { Message = err.Message })); }catch (ClientNotAvalabityException err) { return(StatusCode(401, new { Message = err.Message })); }catch (DateTimeColectedInvalidException err) { return(StatusCode(401, new { Message = err.Message })); }catch (ValuesInvalidException err) { return(StatusCode(401, new { Message = err.Message })); } }
public async Task SaveAppointmentSuccess() { var car = new Car() { Id = 12, }; var client = new Client() { Id = 12, }; var op = new Operator() { Id = 12, }; await _repositoryCar.Add(car); await _repositoryClient.Add(client); await _repositoryOperator.Add(op); var appointment = new Appointment() { Id = 15, DateTimeExpectedCollected = DateTime.Now, DateTimeExpectedDelivery = DateTime.Now.AddDays(10), HourPrice = 10, HourLocation = 10, Subtotal = 100, Amount = 100, IdCar = 12, IdClient = 12, IdOperator = 12 }; Exception exception = null; try { await _service.Execute(appointment); }catch (Exception ex) { exception = ex; } Assert.AreEqual(exception, null); }