Exemplo n.º 1
0
        /// <summary>
        /// Pulls data via HttpGet passing ID
        /// </summary>
        /// <param name="key">Guid value of the record key</param>
        /// <returns>Single record that matches key</returns>
        public async Task <TModel> Get(Guid key)
        {
            var fullUrl = new Uri(MyViewModelWebService.ToStringSafe().AddLast("/") + key.ToString().AddLast("/"), UriKind.RelativeOrAbsolute);

            MyModel = await Sender.SendGetAsync <TModel>(fullUrl);

            return(MyModel);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Pulls record by Id
        /// </summary>
        /// <param name="id">Integer Id of the record to pull</param>
        /// <returns></returns>
        public async Task <TDto> GetByIdAsync(int id)
        {
            var fullUrl = new Uri(MyViewModelWebService.ToStringSafe().AddLast("/") + id.ToString(), UriKind.RelativeOrAbsolute);

            MyModel = await Sender.SendGetAsync <TDto>(fullUrl);

            return(MyModel);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deletes this object from the database via Http Delete
        /// </summary>
        /// <returns>True for success, false for failure</returns>
        public async Task <bool> Delete()
        {
            var returnData = TypeExtension.DefaultBoolean;
            var fullUrll   = new Uri(MyViewModelWebService.ToStringSafe().AddLast("/").AddLast(MyModel.Key.ToString()).AddLast("/"), UriKind.RelativeOrAbsolute);

            returnData = await Sender.SendDeleteAsync(MyViewModelWebService);

            return(returnData);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Pulls all data via HttpGet with ID != TypeExtension.DefaultInteger, and Key != TypeExtension.DefaultGuid
        /// </summary>
        /// <returns></returns>
        public async Task <IEnumerable <TModel> > GetAllExcludeDefault()
        {
            var returnData = new List <TModel>();
            var fullUrl    = new Uri(MyViewModelWebService.ToStringSafe().AddLast("/GetAllExcludeDefault/"), UriKind.RelativeOrAbsolute);

            returnData = await Sender.SendGetAsync <List <TModel> >(fullUrl);

            return(returnData);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Pulls data via HttpGet passing ID
        /// </summary>
        /// <param name="id">Integer value of the record ID</param>
        /// <returns>Single record that matches key</returns>
        public async Task <TModel> Get(int id)
        {
            var returnData = new TModel();
            var fullUrl    = new Uri(MyViewModelWebService.ToStringSafe().AddLast("/") + id.ToString().AddLast("/"), UriKind.RelativeOrAbsolute);

            returnData = await Sender.SendGetAsync <TModel>(fullUrl);

            return(returnData);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Pulls all records from a HttpGet request
        ///  Excludes any record that has an Id == -1 or Key == 00000000-0000-0000-0000-000000000000
        /// </summary>
        /// <returns></returns>
        public async Task <IEnumerable <TDto> > GetAllExcludeDefaultAsync()
        {
            var fullUrl = new Uri(MyViewModelWebService.ToStringSafe().AddLast("/"), UriKind.RelativeOrAbsolute);

            MyModel = new TDto();
            var results = await Sender.SendGetAsync <List <TDto> >(fullUrl);

            return(results.Where(x => x.Key != Guid.Empty));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Deletes this object from the database via Http Delete
        /// </summary>
        /// <returns>True for success, false for failure</returns>
        public async Task <TDto> DeleteAsync()
        {
            var fullUrll = new Uri(MyViewModelWebService.ToStringSafe().AddLast("/").AddLast(MyModel.Id.ToString()).AddLast("/"), UriKind.RelativeOrAbsolute);
            var success  = await Sender.SendDeleteAsync(fullUrll);

            if (success)
            {
                MyModel = new TDto();
            }
            return(MyModel);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Deletes this object from the database via Http Delete
        /// </summary>s
        /// <returns>True for success, false for failure</returns>
        public async Task <bool> Delete()
        {
            var success  = TypeExtension.DefaultBoolean;
            var fullUrll = new Uri(MyViewModelWebService.ToStringSafe().AddLast("/").AddLast(MyModel.ID.ToString()).AddLast("/"), UriKind.RelativeOrAbsolute);

            success = await Sender.SendDeleteAsync(fullUrll);

            if (success)
            {
                MyModel = new TModel();
            }
            return(success);
        }