public void AddWorkOrderImage(AddWorkOrderImageRequest request) { try { HttpClient client = new HttpClient(); client.BaseAddress = new Uri(LAN_Address); //client.DefaultRequestHeaders.Add("appkey", "myapp_key"); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("EO-Header", User + " : " + Pwd); string jsonData = JsonConvert.SerializeObject(request); var content = new StringContent(jsonData, Encoding.UTF8, "application/json"); HttpResponseMessage httpResponse = client.PostAsync("api/Login/AddWorkOrderImage", content).Result; if (httpResponse.IsSuccessStatusCode) { int debug = 1; } } catch (Exception ex) { Exception ex2 = new Exception("AddWorkOrderImage", ex); LogError(ex2.Message, JsonConvert.SerializeObject(request)); } }
public bool AddWorkOrder(bool displayAlert = true) { bool result = false; AddWorkOrderRequest addWorkOrderRequest = new AddWorkOrderRequest(); WorkOrderDTO dto = new WorkOrderDTO() { WorkOrderId = currentWorkOrderId, Seller = ((KeyValuePair <long, string>) this.Seller.SelectedItem).Value, Buyer = this.Buyer.Text, CreateDate = DateTime.Now, DeliveryDate = this.DeliveryDate.Date, Comments = this.Comments.Text, IsSiteService = this.DeliveryType.SelectedIndex == 2 ? true : false, IsDelivery = this.DeliveryType.SelectedIndex == 0 ? false : true, DeliveryType = this.DeliveryType.SelectedIndex, Paid = false, IsCancelled = false, CustomerId = customerId, SellerId = ((KeyValuePair <long, string>) this.Seller.SelectedItem).Key, DeliverTo = DeliverTo.Text, DeliveryRecipientId = deliveryRecipientId, OrderType = OrderType.SelectedIndex, DeliveryUserId = this.DeliveryPerson.SelectedItem != null ? ((KeyValuePair <long, string>) this.DeliveryPerson.SelectedItem).Key : 0 }; addWorkOrderRequest.NotInInventory = notInInventory; List <WorkOrderInventoryMapDTO> workOrderInventoryMap = new List <WorkOrderInventoryMapDTO>(); foreach (WorkOrderInventoryItemDTO woii in workOrderInventoryList) { WorkOrderViewModel wovm = null; if (((ObservableCollection <WorkOrderViewModel>)InventoryItemsListView.ItemsSource).Where(a => a.InventoryId == woii.InventoryId).Any()) { wovm = ((ObservableCollection <WorkOrderViewModel>)InventoryItemsListView.ItemsSource).Where(a => a.InventoryId == woii.InventoryId).First(); } workOrderInventoryMap.Add(new WorkOrderInventoryMapDTO() { WorkOrderId = currentWorkOrderId, InventoryId = woii.InventoryId, InventoryName = woii.InventoryName, //Quantity = woii.Quantity, Quantity = wovm != null ? wovm.Quantity : 1, GroupId = woii.GroupId, Size = woii.Size, }); } addWorkOrderRequest.WorkOrder = dto; addWorkOrderRequest.WorkOrderInventoryMap = workOrderInventoryMap.Where(a => a.GroupId == 0).ToList(); foreach (NotInInventoryDTO notIn in notInInventory) { WorkOrderViewModel wovm = null; if (((ObservableCollection <WorkOrderViewModel>)InventoryItemsListView.ItemsSource).Where(a => a.NotInInventoryId == notIn.NotInInventoryId).Any()) { wovm = ((ObservableCollection <WorkOrderViewModel>)InventoryItemsListView.ItemsSource).Where(a => a.NotInInventoryId == notIn.NotInInventoryId).First(); } if (wovm != null) { notIn.NotInInventoryQuantity = wovm.Quantity; } } addWorkOrderRequest.NotInInventory = notInInventory; addWorkOrderRequest.Arrangements = arrangementList; currentWorkOrderId = ((App)App.Current).AddWorkOrder(addWorkOrderRequest); if (currentWorkOrderId > 0) { result = true; //add any images List <EOImgData> imageData = ((App)App.Current).GetImageData(); if (imageData.Count > 0) { foreach (EOImgData img in imageData) { AddWorkOrderImageRequest request = new AddWorkOrderImageRequest() { WorkOrderId = currentWorkOrderId, ImageId = img.ImageId, Image = img.imgData }; ((App)App.Current).AddWorkOrderImage(request); } } Save.IsEnabled = false; Payment.IsEnabled = true; if (displayAlert) { DisplayAlert("Success", "WorkOrder Saved!", "OK"); } } else { if (displayAlert) { DisplayAlert("Error", "There was an error saving this work order.", "Ok"); } } return(result); }
public long AddWorkOrderImage(AddWorkOrderImageRequest workOrderImageRequest) { return(inventoryManager.AddWorkOrderImage(workOrderImageRequest)); }
public long AddWorkOrderImage(AddWorkOrderImageRequest workOrderImageRequest) { return(persistence.AddWorkOrderImage(workOrderImageRequest)); }