Exemple #1
0
 public async Task <Property> RefreshProperty(Property item)
 {
     return(await ThePropertyDataStore.GetItem(item.id));
 }
Exemple #2
0
        public async Task <bool> Save()
        {
            if (IsBusy)
            {
                return(false);
            }

            IsBusy  = true;
            Message = string.Empty;
            if (String.IsNullOrEmpty(Item.title))
            {
                Message += "请输入标题(please input title)";
            }
            if (String.IsNullOrEmpty(Item.content))
            {
                Message += "\r\n请输入内容(please input content)";
            }
            if (_bufferPath.Count == 0)
            {
                Message += "\r\n请上传图片(please upload pictures)";
            }
            if (String.IsNullOrEmpty(Item.address))
            {
                Message += "\r\n请输入地址(please input address)";
            }

            if (!string.IsNullOrEmpty(Message))
            {
                IsBusy = false;
                return(false);
            }

            try
            {
                Message = "正在连接服务器(connecting)...";
                string id = await ThePropertyDataStore.AddItemAsync(Item);

                int i = 0;
                Item.attachments = new List <Attachment>();
                foreach (string str in _bufferPath)
                {
                    if (str == string.Empty)
                    {
                        break;
                    }
                    Message = String.Format("上传第{0}张图片(uploading image {0})", i + 1);
                    await TheMediaDataStore.UploadImage(str, id, i.ToString());

                    i++;
                }
                if (Item.address != App.CurrentUser.address)
                {
                    App.CurrentUser.address = Item.address.Trim();
                    await TheLoginDataStore.SaveCurrentUser(App.CurrentUser);
                }
                Item = await ThePropertyDataStore.GetItem(id);

                return(true);
            }
            catch (System.Exception ex)
            {
                Message = ErrorMessage.GetMessage(ex.Message);
                IsBusy  = false;
                return(false);
            }
            finally
            {
                IsBusy  = false;
                Message = string.Empty;
            }
        }