// PUT: api/Users/5 public bool Put(int id, [FromBody] User user) { user.Id = id; if (!CheckNoDuplicate(user)) { return(false); } //CleanUserStrings(user); return(manager.Put(Extractables.ExtractUser(user), PrimaryKeys(id))); }
// POST: api/Users public bool Post([FromBody] User user) { user.Id = -1; if (CheckNoDuplicate(user)) { //CleanUserStrings(user); return(manager.Post(Extractables.ExtractUser(user))); } return(false); }
// POST: api/Messages public bool Post([FromBody] Message message) { //string content = message.ToString(); //string[] splitContent = content.Split(new [] {','},2); //string idString = splitContent[0].Remove(0, splitContent[0].IndexOf(":")+2); //string messageString = splitContent[1].Remove(0, splitContent[1].IndexOf(":")+2); //messageString = messageString.TrimEnd(new char[]{'}', '\r', '\n'}).Trim('"'); //MessagesManager.Post(Extractables.ExtractMessage(Convert.ToInt32(idString), messageString)); return(messageManager.Post(Extractables.ExtractMessage(message))); }
private void Clean() { try { manager.Delete(PrimaryKeys(0)); if (actualData.Name != string.Empty || actualData.Address != string.Empty) //Only put data back in if it is worthwhile data. { manager.Post(Extractables.ExtractHotel(actualData)); } } catch (Exception e) { } }
public void ManagerPost_PostCompletes() { Setup(); try { manager.Post(Extractables.ExtractHotel(testHotel)); } catch (Exception e) { Assert.Fail(e.Message); } Clean(); }
// PUT: api/Bookings/5 public bool Put(int id, [FromBody] Booking booking) { //bool settingsOk = bookingSettingsManager.Put(Extractables.ExtractBookingSettings(booking), PrimaryKeys(id)); bookedEventsManager.Delete(PrimaryKeys(id)); bool bookedOk = true; foreach (int eventId in booking.BookedEventsId) { bookedOk = bookedEventsManager.Post(Extractables.ExtractBookedEvents(booking.UserId, eventId)); } return(bookedOk); }
public void ManagerPut_PutCompletes() { Setup(); Hotel editedHotel = new Hotel(0, "OtherHotel", "OtherStreet"); try { manager.Put(Extractables.ExtractHotel(editedHotel), PrimaryKeys(0)); } catch (Exception e) { Assert.Fail(e.Message); } Clean(); }
// POST: api/Bookings public bool Post([FromBody] Booking booking) { bool settingsOk = bookingSettingsManager.Post(Extractables.ExtractBookingSettings(booking)); bool bookedOk = false; if (settingsOk) { bookedOk = true; foreach (int eventId in booking.BookedEventsId) { bookedOk = bookedEventsManager.Post(Extractables.ExtractBookedEvents(booking.UserId, eventId)); } } return(settingsOk && bookedOk); }
// POST: api/Events public bool Post([FromBody] Event sikonEvent) { _initialIds = GetAllIds(); bool eventOk = eventManager.Post(Extractables.ExtractEvent(sikonEvent)); bool speakersInEventOk = false; if (eventOk) { sikonEvent.EventID = RetrieveId(); speakersInEventOk = true; foreach (Speaker speaker in sikonEvent.SpeakersInEvent) { speakersInEventOk = speakersInEventManager.Post(Extractables.ExtractSpeakersInEvent(sikonEvent.EventID, speaker.Id)); } } return(eventOk && speakersInEventOk); }
// PUT: api/Events/5 public bool Put(int id, [FromBody] Event sikonEvent) { bool eventOk = eventManager.Put(Extractables.ExtractEvent(sikonEvent), PrimaryKeys(id)); bool speakersInEventOk = false; if (eventOk) { speakersInEventManager.Delete(PrimaryKeys(id)); speakersInEventOk = true; foreach (Speaker speaker in sikonEvent.SpeakersInEvent) { speakersInEventOk = speakersInEventManager.Post(Extractables.ExtractSpeakersInEvent(sikonEvent.EventID, speaker.Id)); } } return(eventOk && speakersInEventOk); }
public void ManagerPut_WhenNoRecordIsFound_ReturnsFalse() { Setup(); bool expected = false; bool actual = true; Hotel editedHotel = new Hotel(0, "OtherHotel", "OtherStreet"); try { actual = manager.Put(Extractables.ExtractHotel(editedHotel), PrimaryKeys(0)); } catch (Exception e) { Assert.Fail(e.Message); } Clean(); Assert.AreEqual(expected, actual); }
public void ManagerPost_DuplicatePost() { Setup(); bool expected = false; bool actual = true; try { manager.Post(Extractables.ExtractHotel(testHotel)); actual = manager.Post(Extractables.ExtractHotel(testHotel)); } catch (Exception e) { Assert.Fail(e.Message); } Clean(); Assert.AreEqual(expected, actual); }
public void ManagerDeleteAndPostAndGetOne_DataIsDeletedFromDatabase() { Setup(); Hotel deletedHotel = new Hotel(); try { manager.Post(Extractables.ExtractHotel(testHotel)); manager.Delete(PrimaryKeys(0)); deletedHotel = manager.GetOne(Fillables.FillHotel, PrimaryKeys(0)); } catch (Exception e) { Assert.Fail(e.Message); } Clean(); Assert.IsNull(deletedHotel); }
// PUT: api/Speakers/5 public bool Put(int id, [FromBody] Speaker speaker) { speaker.Id = id; if (!CheckNoDuplicate(speaker)) { return(false); } bool speakerOk = speakerManager.Put(Extractables.ExtractSpeaker(speaker), PrimaryKeys(id)); bool userOk = false; if (speakerOk) { userOk = userManager.Put( Extractables.ExtractUser(speaker), PrimaryKeys(id)); } return(speakerOk && userOk); }
// POST: api/Speakers public bool Post([FromBody] Speaker speaker) { speaker.Id = -1; bool userOk = false; if (CheckNoDuplicate(speaker)) { userOk = userManager.Post(Extractables.ExtractUser(speaker)); } bool speakerOk = false; if (userOk) { speaker.Id = RetrieveId(speaker); speakerOk = speakerManager.Post(Extractables.ExtractSpeaker(speaker)); } return(userOk && speakerOk); }
// PUT: api/Admins/5 public bool Put(int id, [FromBody] Admin admin) { admin.Id = id; if (!CheckNoDuplicate(admin)) { return(false); } bool adminOk = adminManager.Put(Extractables.ExtractAdmin(admin), PrimaryKeys(id)); bool userOk = false; if (adminOk) { //UsersController.CleanUserStrings(user); userOk = userManager.Put(Extractables.ExtractUser(admin), PrimaryKeys(id)); } return(adminOk && userOk); }
// POST: api/Admins public bool Post([FromBody] Admin admin) { admin.Id = -1; bool userOk = false; if (CheckNoDuplicate(admin)) { userOk = userManager.Post(Extractables.ExtractUser(admin)); } bool adminOk = false; if (userOk) { admin.Id = RetrieveId(admin); adminOk = adminManager.Post(Extractables.ExtractAdmin(admin)); } return(userOk && adminOk); }
public void ManagerPostAndGetOne_DataIsPostedAndDataIsRead() { Setup(); Hotel actual = null; try { manager.Post(Extractables.ExtractHotel(testHotel)); actual = manager.GetOne(Fillables.FillHotel, PrimaryKeys(0)); } catch (Exception e) { Assert.Fail(e.Message); } Clean(); Assert.IsNotNull(actual); Assert.AreEqual(testHotel.HotelNo, actual.HotelNo); Assert.AreEqual(testHotel.Name, actual.Name); Assert.AreEqual(testHotel.Address, actual.Address); }
// POST: api/Bookings public bool Post([FromBody] Booking booking) //Beware of cultural differences with dates { return(manager.Post(Extractables.ExtractBooking(booking))); }
// PUT: api/BookingSettings/5 public bool Put(int id, [FromBody] Booking booking) { return(bookingSettingsManager.Put(Extractables.ExtractBookingSettings(booking), BookingsController.PrimaryKeys(id))); }
// POST: api/BookingSettings public bool Post([FromBody] Booking booking) { return(bookingSettingsManager.Post(Extractables.ExtractBookingSettings(booking))); }
public bool Put(int roomNo, int hotelNo, [FromBody] Room room) { return(manager.Put(Extractables.ExtractRoom(room), PrimaryKeys(roomNo, hotelNo))); }
// POST: api/Rooms public bool Post([FromBody] Room room) { return(manager.Post(Extractables.ExtractRoom(room))); }
// PUT: api/Hotels/5 public bool Put(int id, [FromBody] Hotel hotel) { return(manager.Put(Extractables.ExtractHotel(hotel), PrimaryKeys(id))); }
// POST: api/Hotels public bool Post([FromBody] Hotel hotel) { return(manager.Post(Extractables.ExtractHotel(hotel))); }
// PUT: api/Rooms/5 public bool Put(int id, [FromBody] Room room) { return(roomManager.Put(Extractables.ExtractRoom(room), PrimaryKeys(id))); }
// PUT: api/Guests/5 public bool Put(int id, [FromBody] Guest guest) { return(manager.Put(Extractables.ExtractGuest(guest), PrimaryKeys(id))); }
// POST: api/Guests public bool Post([FromBody] Guest guest) { return(manager.Post(Extractables.ExtractGuest(guest))); }
// PUT: api/Bookings/5 public bool Put(int id, [FromBody] Booking booking) { return(manager.Put(Extractables.ExtractBooking(booking), PrimaryKeys(id))); }