public IActionResult CreateWorkplaceOrder([FromBody] WorkplaceOrder WorkplaceOrder) { string userJWTId = User.FindFirst("id")?.Value; Client client = clientDB.GetCurrentClient(userJWTId); if (client == null) { return(NotFound()); } WorkplaceOrder.ClientId = client.Id; if (OrderWorkplace.isFree(WorkplaceOrder.ClientId, WorkplaceOrder.WorkplaceId, WorkplaceOrder.StartTime, WorkplaceOrder.FinishTime)) { WorkplaceOrder.SumToPay = OrderWorkplace.CreateOrder(WorkplaceOrder.ClientId, WorkplaceOrder.WorkplaceId, WorkplaceOrder.StartTime, WorkplaceOrder.FinishTime); WorkplaceOrderDB.Create(WorkplaceOrder); WorkplaceOrderDB.Save(); WorkplaceOrder.Client = null; WorkplaceOrder.Workplace = null; return(Ok(WorkplaceOrder)); } return(BadRequest()); }
public IActionResult UpdateWorkplaceOrder([FromBody] WorkplaceOrder WorkplaceOrder) { if (WorkplaceOrder == null) { return(BadRequest()); } WorkplaceOrderDB.Update(WorkplaceOrder); WorkplaceOrderDB.Save(); return(Ok(WorkplaceOrder)); }
public IActionResult GetWorkplaceOrderById(int id) { WorkplaceOrder WorkplaceOrder = WorkplaceOrderDB.GetEntity(id); if (WorkplaceOrder == null) { return(NotFound()); } return(new ObjectResult(WorkplaceOrder)); }
public IActionResult DeleteWorkplaceOrder(int id) { WorkplaceOrder WorkplaceOrder = WorkplaceOrderDB.GetEntity(id); if (WorkplaceOrder == null) { return(NotFound()); } WorkplaceOrderDB.Delete(id); WorkplaceOrderDB.Save(); return(Ok(WorkplaceOrder)); }
public IActionResult CreateWorkplaceOrder([FromBody] WorkplaceOrder WorkplaceOrder) { if (!ModelState.IsValid) { return(BadRequest()); } if (OrderWorkplace.isFree(WorkplaceOrder.ClientId, WorkplaceOrder.WorkplaceId, WorkplaceOrder.StartTime, WorkplaceOrder.FinishTime)) { WorkplaceOrder.SumToPay = (int)OrderWorkplace.CreateOrder(WorkplaceOrder.ClientId, WorkplaceOrder.WorkplaceId, WorkplaceOrder.StartTime, WorkplaceOrder.FinishTime); WorkplaceOrderDB.Create(WorkplaceOrder); WorkplaceOrderDB.Save(); WorkplaceOrder.Client = null; WorkplaceOrder.Workplace = null; return(Ok(WorkplaceOrder)); } return(Ok("Busy")); }
public void ManageSelectdDataButton(DateTime time) { ClearTextViews(); orderedTimes.Clear(); orderedTimes.Add(new TimeSpan(21, 0, 0)); List <TimeSpan> newDT = new List <TimeSpan>(busyTimes); foreach (WorkplaceOrder workplaceOrder in workplaceOrders) { if (workplaceOrder.WorkplaceId == workplaceId && workplaceOrder.StartTime.Value.Year == time.Year && workplaceOrder.StartTime.Value.Month == time.Month && workplaceOrder.StartTime.Value.Day == time.Day) { for (int i = newDT.Count - 1; i >= 0; i--) { bool moreCriteria = false; bool lessCriteria = false; if (newDT[i].Hours == workplaceOrder.StartTime.Value.Hour) { moreCriteria = newDT[i].Minutes >= workplaceOrder.StartTime.Value.Minute; } else if (newDT[i].Hours > workplaceOrder.StartTime.Value.Hour) { moreCriteria = true; } if (newDT[i].Hours == workplaceOrder.FinishTime.Value.Hour) { lessCriteria = newDT[i].Minutes < workplaceOrder.FinishTime.Value.Minute; } else if (newDT[i].Hours < workplaceOrder.FinishTime.Value.Hour) { lessCriteria = true; } if (moreCriteria && lessCriteria) { orderedTimes.Add(newDT[i]); newDT.RemoveAt(i); } } } orderedTimes.Sort(); } LinearLayout linearLayout = FindViewById <LinearLayout>(Resource.Id.workplace_layout); for (int i = 0; i < newDT.Count; i++) { Button textView = new Button(this) { Text = newDT[i].ToString(), Id = i }; textView.Click += (s, arg) => { TimeSpan start = newDT[textView.Id]; selectedTime = start; TimeSpan finish = orderedTimes.FirstOrDefault(x => x > start); PopupMenu menu = new PopupMenu(this, textView); while (!(start.Hours == finish.Hours && start.Minutes == finish.Minutes)) { Console.WriteLine((finish - start).ToString()); menu.Menu.Add((finish - start).ToString()); finish -= new TimeSpan(0, 30, 0); } menu.MenuItemClick += async(s1, arg1) => { TimeSpan dur = TimeSpan.Parse(arg1.Item.TitleFormatted.ToString()); WorkplaceOrder workplaceOrder = new WorkplaceOrder(); workplaceOrder.ClientId = client.Id; workplaceOrder.WorkplaceId = workplaceId; workplaceOrder.StartTime = new DateTime(selectetDate.Year, selectetDate.Month, selectetDate.Day, selectedTime.Hours, selectedTime.Minutes, selectedTime.Seconds); TimeSpan fin = dur + selectedTime; workplaceOrder.FinishTime = new DateTime(selectetDate.Year, selectetDate.Month, selectetDate.Day, fin.Hours, fin.Minutes, fin.Seconds); workplaceOrder = await apiClient.CreateWorkplaceOrderAsync(workplaceOrder); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Creation"); alert.SetMessage("Created, Total cost: " + workplaceOrder.SumToPay.ToString()); alert.SetPositiveButton("OK", async(senderAlert, arg2) => { int amound = dur.Hours * 2 + ((dur.Minutes == 30) ? 1 : 0); for (int j = textView.Id; j < (textView.Id + amound); j++) { linearLayout.RemoveView(timeTextViews[j]); orderedTimes.Add(newDT[j]); } orderedTimes.Sort(); }); Dialog dialog = alert.Create(); dialog.Show(); }; menu.Show(); }; timeTextViews.Add(textView); linearLayout.AddView(textView); } }