Пример #1
0
        private async void SaveAction()
        {
            var item = new ModelsShared.Models.userprofile
            {
                Address   = this.Address,
                FirstName = this.FirstName,
                LastName  = this.LastName,
                UserId    = this.UserId,
                Photo     = this.Photo,
                UserName  = this.UserName
            };

            bool result = false;

            if (IsNew)
            {
                result = await MainVM.UserProfileCollections.Add(item);
            }
            else
            {
                result = await MainVM.UserProfileCollections.Update(this.UserId, item);
            }

            if (result)
            {
                ResourcesBase.ShowMessage("Data Berhasil Disimpan");
            }
            else
            {
                ResourcesBase.ShowMessageError("Data Tidak Tersimpan");
            }
        }
        public async Task <bool> Add(userprofile item)
        {
            try
            {
                var           obj     = JsonConvert.SerializeObject(item);
                StringContent content = new StringContent(obj);
                var           result  = await client.ClientContext.PostAsync("/Api/UserProfile", content);

                if (result.IsSuccessStatusCode)
                {
                    var newitem = JsonConvert.DeserializeObject <userprofile>(result.Content.ReadAsStringAsync().Result);
                    this.Source.Add(newitem);
                    return(true);
                }
                else
                {
                    throw new SystemException("Data Tidak Tersimpan");
                }
            }
            catch (Exception ex)
            {
                ResourcesBase.ShowMessageError(ex.Message);
                return(false);
            }
        }
Пример #3
0
        public void Add(T item)
        {
            Client        client  = new Client();
            var           obj     = JsonConvert.SerializeObject(item);
            StringContent content = new StringContent(obj, Encoding.UTF8, "application/json");

            try
            {
                var response = client.ClientContext.PostAsync(uri, content).Result;
                if (response.IsSuccessStatusCode == true)
                {
                    var result = JsonConvert.DeserializeObject <T>(response.Content.ReadAsStringAsync().Result);
                    if (response != null)
                    {
                        list.Add(result);
                        OnChangeSource?.Invoke(result);
                        SourceView.Refresh();
                    }
                    ResourcesBase.ShowMessage("Data Berhasil Ditambah");
                }
                else
                {
                    throw new SystemException(response.ReasonPhrase);
                }
            }
            catch (Exception ex)
            {
                ResourcesBase.ShowMessageError(ex.Message);
            }
        }
Пример #4
0
        public bool  Remove(T item)
        {
            dynamic a      = item;
            var     ApiUrl = uri + "?id=" + a.Id;

            try
            {
                if (ResourcesBase.MessageAsk("Yakin Hapus Data ?"))
                {
                    Client client   = new Client();
                    var    response = client.ClientContext.DeleteAsync(ApiUrl).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        list.Remove(item);
                        OnChangeSource(item);
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ResourcesBase.ShowMessageError(ex.Message);
                return(false);
            }
        }
Пример #5
0
 private void DeletePackAction()
 {
     if (SimulationPack.PackSelectedItem.PackingLists.Count > 0)
     {
         ResourcesBase.ShowMessageError("Kosongkan Pack Sebelum Dihapus");
     }
     else
     {
         SimulationPack.Packs.Remove(SimulationPack.PackSelectedItem);
         SimulationPack.PacksView.Refresh();
     }
 }
Пример #6
0
 private void SetAbsenAction(object obj)
 {
     if (SelectedItem != null)
     {
         if (string.IsNullOrEmpty(SelectedItem.Enrollment))
         {
             ResourcesBase.ShowMessageError("Sidik Jari Belum Didaftarkan");
         }
         else
         {
             var form = new Forms.AbsenVerification(SelectedItem);
             form.Show();
         }
     }
 }
Пример #7
0
        private async void SaveAction()
        {
            var list = new List <string>();

            foreach (var i in Ports)
            {
                list.Add(i.Name);
            }
            this.RouteView = list;
            var item = new ModelsShared.Models.ship {
                Description = this.Description, Name = this.Name, Id = this.Id, Route = this.Route
            };
            var result = await MainVM.ShipCollection.Add(item);

            if (result == null)
            {
                ResourcesBase.ShowMessageError("Data Tidak Tersimpan");
            }
            else
            {
                Cancel.Execute(null);
            }
        }