public override void Save() { FileStream objStream = new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); XmlTextWriter objWriter = new XmlTextWriter(objStream, Encoding.UTF8) { Formatting = Formatting.Indented, Indentation = 1, IndentChar = '\t' }; //Start Doc objWriter.WriteStartDocument(); objWriter.WriteStartElement("Item"); objWriter.WriteElementString("Type", "CyberMod"); //Write Universal item Info objWriter.WriteElementString("Name", Name); objWriter.WriteElementString("Description", Description); objWriter.WriteElementString("Rules", Rules); //objWriter.WriteElementString("Picture", picture); TODO: Picture objWriter.WriteElementString("Availability", Avail.ToString()); objWriter.WriteElementString("Cost", Cost.ToString()); objWriter.WriteElementString("DeviceRating", DeviceRating.ToString()); objWriter.WriteElementString("Weight", Weight.ToString()); //End Doc objWriter.WriteEndElement(); objWriter.WriteEndDocument(); objWriter.Close(); objStream.Close(); }
public void AddAvailToOrder(Avail avail, int id) { var foundOrder = _db.Orders.Find(id); foundOrder.Avails.Add(avail); _db.Entry(foundOrder).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); }
protected override void Seed(CarService.Model.CarServiceContext context) { var availStatusesToSave = new List <AvailStatus>() { new AvailStatus() { StatusName = AvailStatusEnum.WaitingForParts.GetStringValue() }, new AvailStatus() { StatusName = AvailStatusEnum.NoWork.GetStringValue() }, new AvailStatus() { StatusName = AvailStatusEnum.WorkInProgress.GetStringValue() }, new AvailStatus() { StatusName = AvailStatusEnum.OrderingTheMissingParts.GetStringValue() }, new AvailStatus() { StatusName = AvailStatusEnum.Finished.GetStringValue() } }; foreach (var item in availStatusesToSave) { context.AvailStatuses.AddOrUpdate(o => o.StatusName, item); } context.SaveChanges(); var availstatus = context.AvailStatuses.FirstOrDefault(o => o.Id == 1); var customerToSave = new Customer() { NameAndSurname = "Kamila Wróbel", NIP = "12345667", PhoneNumber = "51216193" }; context.Customers.Add(customerToSave); context.SaveChanges(); var customer = context.Customers.FirstOrDefault(o => o.NameAndSurname == "Kamila Wróbel"); var carToSave = new Car() { Model = "Fruzia", CustomerId = customer.Id, Type = "sedan", Mark = "Renault", RegistrationNumber = "WWL3NK4", VIN = "1234" }; context.Cars.Add(carToSave); context.SaveChanges(); var car = context.Cars.FirstOrDefault(o => o.Model == "Fruzia"); context.Orders.Add(new Order() { IsDone = false, InitialPrice = 232, OrderDate = new DateTime(2008, 5, 1), DeclaredFinishDate = new DateTime(2009, 10, 1), CustomerId = customer.Id }); //Avails = new List<Avail>() { avail } }); context.SaveChanges(); context.Orders.Add(new Order() { IsDone = false, InitialPrice = 282, OrderDate = new DateTime(2008, 5, 2), DeclaredFinishDate = new DateTime(2009, 10, 2), CustomerId = customer.Id }); //Avails = new List<Avail>() { avail } }); context.SaveChanges(); var usedPartsToSave = new List <Part>() { new Part() { IsReplacement = false, Manufacturer = "Stasiek", Name = "filtr", Price = 50 } }; var usedPartsToSaveTwo = new List <Part>() { new Part() { IsReplacement = true, Manufacturer = "Karol Suska", Name = "ko³o", Price = 500 } }; var availToSave = new Avail() { Duration = 3, Type = "Czyszczenie klimatyzacji", CarId = car.Id, UsedParts = usedPartsToSave, AvailStatusId = availstatus.Id, OrderId = 1 }; var availToSaveTwo = new Avail() { Duration = 4, Type = "Wymiana ko³a", CarId = car.Id, UsedParts = usedPartsToSaveTwo, AvailStatusId = availstatus.Id, OrderId = 1 }; context.Avails.Add(availToSave); context.Avails.Add(availToSaveTwo); context.SaveChanges(); //var avail = context.Avails.FirstOrDefault(o => o.Type == "Czyszczenie klimatyzacji"); //context.Orders.Add(new Order() { IsDone = true, InitialPrice = 231, OrderDate = new DateTime(2016, 1, 1), DeclaredFinishDate = new DateTime(2016, 2, 15), CustomerId = customer.Id, Avails = new List<Avail>() { avail } }); //context.SaveChanges(); //context.Orders.Add(new Order() { IsDone = false, InitialPrice = 231, OrderDate = new DateTime(2016, 1, 1), DeclaredFinishDate = new DateTime(2015, 4, 1), CustomerId = customer.Id, Avails = new List<Avail>() { avail } }); //context.SaveChanges(); }
public override int GetHashCode() { return(Number.GetHashCode() ^ Avail.GetHashCode() ^ Size.GetHashCode()); }
public IHttpActionResult AddAvailToOrder([FromBody] Avail avail, int id) { _orderService.AddAvailToOrder(avail, id); return(Ok()); }
private void button2_Click(object sender, EventArgs e) { //capture the booking details from the textboxes if (comboBox1.SelectedIndex == -1)//Nothing selected { MessageBox.Show("Please select number of guests from the drop down list", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboBox1.Focus(); return; } else if (dateTimePicker2.Value < dateTimePicker1.Value) { MessageBox.Show("Check out date should be a later date than the check in date", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); dateTimePicker1.Focus(); return; } else { //check the availability Collection <Room> Avail; Avail = bookingController.CheckAvailability(dateTimePicker1.Value.Date, dateTimePicker2.Value.Date, roomController.AllRooms); DialogResult result; Booking aBooking; //if there are bookings available if (Avail.Count() > 0) { result = MessageBox.Show("Booking for " + dateTimePicker1.Value.ToShortDateString() + " - " + dateTimePicker2.Value.ToShortDateString() + " is available\nClick yes to confirm", "Confirm Reservation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { this.Hide(); //make the booking with all the fields we currently have aBooking = new Booking(); aBooking.BookingID = bookingController.GenerateBookingID(); aBooking.ReservationDate = DateTime.Today.ToShortDateString(); aBooking.StartDate = dateTimePicker1.Value.ToShortDateString(); aBooking.EndDate = dateTimePicker2.Value.ToShortDateString(); aBooking.RoomNumber = Avail[0].RoomNumber; //assigned to the first available room aBooking.NoOfGuests = comboBox1.SelectedItem.ToString(); aBooking.Price = bookingController.CalculateBookingPrice(dateTimePicker1.Value, dateTimePicker2.Value, roomRateController.AllRoomRates); aBooking.DepositAmount = (aBooking.Price / 10); aBooking.DepositPaid = "false"; ReservationDetailsDisplayForm obj = new ReservationDetailsDisplayForm(bookingController, roomController, guestController, aBooking, paymentController); //this must change to the capture guest details obj.Show(); } if (result == DialogResult.No) //if they want to stay on this page { } } //if there are no bookings available else { result = MessageBox.Show("Reservation unavailable\nPlease select new dates", "Reservation Unvailable", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); //to select new dates if (result == DialogResult.OK) { } } } }