Exemplo n.º 1
0
        private async void OnSaveCommandExecuted()
        {
            try
            {
                if (IsNew)
                {
                    InventoryViability newInventoryViability = new InventoryViability()
                    {
                        InventoryViabilityId       = -1,
                        InventoryViabilityRuleId   = SelectedInventoryViabilityRule.InventoryViabilityRuleId,
                        InventoryViabilityRuleName = SelectedInventoryViabilityRule.Name,
                        InventoryId      = InventoryId,
                        ReplicationCount = ReplicationCount,
                        TotalTestedCount = TotalTestedCount,
                        TestedDateCode   = "MM/dd/yyyy",
                        TestedDate       = TestedDate
                    };
                    string result = await _restService.CreateInventoryViabilityAsync(newInventoryViability);

                    await _pageDialogService.DisplayAlertAsync("New Inventory Viability Id", result, "OK");

                    newInventoryViability.InventoryViabilityId = int.Parse(result);
                    var navigationParams = new NavigationParameters();
                    navigationParams.Add("InventoryViability", newInventoryViability);

                    await NavigationService.GoBackAsync(navigationParams);
                }
                else
                {
                    InventoryViability.InventoryViabilityRuleId   = SelectedInventoryViabilityRule.InventoryViabilityRuleId;
                    InventoryViability.InventoryViabilityRuleName = SelectedInventoryViabilityRule.Name;
                    InventoryViability.ReplicationCount           = ReplicationCount;
                    InventoryViability.TotalTestedCount           = TotalTestedCount;
                    InventoryViability.TestedDate     = TestedDate;
                    InventoryViability.TestedDateCode = "MM/dd/yyyy";

                    string result = await _restService.UpdateInventoryViabilityAsync(InventoryViability);

                    //await _pageDialogService.DisplayAlertAsync("result", result, "OK");

                    var navigationParams = new NavigationParameters();
                    navigationParams.Add("InventoryViability", InventoryViability);

                    await NavigationService.GoBackAsync(navigationParams);
                }
            }
            catch (Exception e)
            {
                await _pageDialogService.DisplayAlertAsync("Error", e.Message, "OK");
            }
        }
Exemplo n.º 2
0
        public async Task <string> UpdateInventoryViabilityAsync(InventoryViability item)
        {
            string result = string.Empty;

            var           data     = JsonConvert.SerializeObject(JsonConvert.SerializeObject(item));
            StringContent content  = new StringContent(data, Encoding.UTF8, "application/json");
            var           response = await _httpClient.PutAsync(string.Format(RestUrlRUD, Settings.Server, "inventory_viability", item.InventoryViabilityId), content);

            string resultContent = response.Content.ReadAsStringAsync().Result;

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                //result = JsonConvert.DeserializeObject<List<InventoryViability>>(resultContent);
                result = resultContent;
            }
            else
            {
                throw new Exception(resultContent);
            }

            return(result);
        }
Exemplo n.º 3
0
 public Task SaveInventoryViability(InventoryViability item, bool isNewItem)
 {
     throw new NotImplementedException();
 }