public Task(string name, Customer assignedCustomer, Address destination, double income, List <DateTime> Ldates, string description, string workPhoneNumber, int phase) { this.Phase = phase; this.Name = name; this.Customer = assignedCustomer; this.Destination = destination; this.Income = income; this.Description = description; foreach (DateTime date in Ldates) { DateTimes temp = new DateTimes(); temp.Date = date; Dates.Add(temp); } this.WorkPhoneNumber = workPhoneNumber; this.IsPaused = false; this.PhotoPath = "assets/images/tasks/placeholder.png"; }
public Moving PopulateMovingTask(dynamic temp, Moving movingtask) { string Saddress = temp.StartAddress; string SZIP = temp.StartZIP; string SCity = temp.StartCity; //destination string Daddress = temp.DestinationAddress; string DZIP = temp.DestinationZIP; string DCity = temp.DestinationCity; string notes = temp.Notes; Address startingAddress = new Address(Saddress, SZIP, SCity); Address destination = new Address(Daddress, DZIP, DCity); movingtask.StartingAddress = startingAddress; movingtask.Destination = destination; int customerID = temp.CustomerID; int employeeID = temp.EmployeeID; int carID = temp.CarID; bool withPacking; if (temp.WithPacking != null) { withPacking = true; } else { withPacking = false; } Customer tempCustomer = database.Customers.FirstOrDefault(cus => cus.ID == customerID); Employee tempEmployee = database.Employees.FirstOrDefault(emp => emp.ID == employeeID); Vehicle tempCar = database.Equipment.OfType <Vehicle>().FirstOrDefault(car => car.ID == carID); movingtask.Customer = tempCustomer; Tool tempTool; string name; if (tempCustomer.GetType() == typeof(Private)) { Private cus = (Private)tempCustomer; name = cus.Firstname + ' ' + cus.Lastname; } else if (tempCustomer.GetType() == typeof(Public)) { Public cus = (Public)tempCustomer; name = cus.Name; } else { Business cus = (Business)tempCustomer; name = cus.Name; } int lentBoxes = temp.Lentboxes; string inspection = temp.InspectionDate; string moving = temp.MovingDate; DateTime inspectionDate = DateTime.Parse(inspection, CultureInfo.GetCultureInfo("sv-SE")); DateTime movingDate = DateTime.Parse(moving, CultureInfo.GetCultureInfo("sv-SE")); DateTime endDate = movingDate.AddHours(2); List <DateTime> tempDates = new List <DateTime>(); tempDates.Add(movingDate); tempDates.Add(endDate); movingtask.Name = name + "'s opgave"; movingtask.Income = 0; foreach (DateTime date in tempDates) { DateTimes tempdate = new DateTimes(); tempdate.Date = date; movingtask.Dates.Add(tempdate); } movingtask.Description = notes; movingtask.LentBoxes = lentBoxes; movingtask.WithPacking = withPacking; movingtask.Phase = 3; if (temp.ToolID != null) { int toolID = temp.ToolID; tempTool = database.Equipment.OfType <Tool>().FirstOrDefault(tool => tool.ID == toolID); movingtask.Equipment.Add(new TaskAssignedEquipment() { Equipment = tempTool }); } movingtask.Equipment.Add(new TaskAssignedEquipment() { Equipment = tempCar }); movingtask.Employees.Add(new TaskAssignedEmployees() { Employee = tempEmployee }); return(movingtask); }