public async Task <ActionResult> RegisterRoom(BookRoomDto bookRoom) { if (!await _clientRepo.ClientExists(bookRoom.Email)) { return(StatusCode(400, new { Error = "Client has not been registered, kindly register before booking a room" })); } if (await _clientRepo.ClientExists(bookRoom.RoomNo, string.Concat(bookRoom.FirstName, bookRoom.LastName))) { return(StatusCode(400, new { Error = "Client has already booked this room" })); } var _bookRoom = await _roomRepo.BookRoom(bookRoom); if (_bookRoom == null) { return(StatusCode(500, new { Error = "Could not book room." })); } else { //send mail to admin _emailer.SendEmailToAdmin(_bookRoom); return(StatusCode(201, _bookRoom)); } }
public async Task <ActionResult> RegisterClient(ClientCreateDto client) { if (await _clientRepo.ClientExists(client.Email)) { return(StatusCode(400, new { Error = $"{client.Email} is a registered client already" })); } var _client = await _clientRepo.AddClient(client); if (_client == null) { return(StatusCode(500, new { Error = "Could not register client." })); } else { //send mail to customer _emailer.SendEmailToClient(client); return(StatusCode(201, _mapper.Map <ClientDisplayDto>(_client))); } }