public ActionResult <AddRegistrationResource> GetAddRegistrationResourceSample() { var sample = new AddRegistrationResource() { ClientName = "Bob Cobich", Phone = "67843298", RoomId = new Guid(), RegistrationId = new Guid(), Start = DateTime.Now, End = DateTime.Now }; return(Ok(sample)); }
public ActionResult <RegistrationDTO> Edit([FromBody] AddRegistrationResource resource) { var reg = _repository.GetRegistration(resource.RegistrationId); var client = _repository.GetOrAddClient(resource.ClientName, resource.Phone); var room = _repository.GetRoom(resource.RoomId); reg.ClientId = client.Id; reg.RoomId = resource.RoomId; reg.Room = room; reg.CheckInDate = resource.Start; reg.CheckOutDate = resource.End; _repository.SaveChanges(); return(Ok(new RegistrationDTO(reg))); }
public ActionResult <RegistrationDTO> Add([FromBody] AddRegistrationResource resource) { var client = _repository.GetOrAddClient(resource.ClientName, resource.Phone); var room = _repository.GetRoom(resource.RoomId); var reg = new Registration() { Id = new Guid(), ClientId = client.Id, Client = client, RoomId = room.Id, Room = room, CheckInDate = resource.Start, CheckOutDate = resource.End }; _repository.AddRegistation(reg); return(Ok(new RegistrationDTO(reg))); }