コード例 #1
0
        //public async Task<UserEventList> GetUserEventList(int ID)
        //{
        //    UserEventList returnMe = null;
        //    try
        //    {
        //        returnMe = await database.Table<UserEventList>().Where(d => d.ID == ID).FirstOrDefaultAsync();
        //    }
        //    catch (Exception)
        //    {

        //    }
        //    return returnMe;
        //}

        public async Task <UserEventList> AddUserEventList(string title)
        {
            bool   nameExists = true;
            string newTitle   = title;

            var countAdd = 0;

            while (nameExists)
            {
                nameExists = await database.Table <UserEventList>().Where(d => d.Title.ToLower() == newTitle.ToLower()).CountAsync() > 0;

                if (nameExists)
                {
                    countAdd++;
                    newTitle = title + $" ({countAdd})";
                }
            }

            UserEventList newList = new UserEventList()
            {
                Title = newTitle
            };

            await database.InsertAsync(newList);

            return(newList);
        }
コード例 #2
0
        public async Task <UserEventList> UpdateUserEventList(UserEventList list, bool withChildren = false)
        {
            bool   nameExists = true;
            string newTitle   = list.Title;

            var countAdd = 0;

            while (nameExists)
            {
                nameExists = await database.Table <UserEventList>().Where(d => d.Title.ToLower() == newTitle.ToLower() && d.ID != list.ID).CountAsync() > 0;

                if (nameExists)
                {
                    countAdd++;
                    newTitle = list.Title + $" ({countAdd})";
                }
            }

            list.Title = newTitle;

            if (withChildren)
            {
                await database.InsertOrReplaceWithChildrenAsync(list);
            }
            else
            {
                await database.InsertOrReplaceAsync(list);
            }
            return(list);
        }
コード例 #3
0
        public async Task <UserEventList> InsertUpdateUserEventListAsync(UserEventList submitMe)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    client.Timeout = new TimeSpan(0, 0, 15);

                    //client.BaseAddress = new Uri(GlobalVars.UserEventListURL);
                    var viewModelSubmit = new UserEventListViewModel
                    {
                        Title           = submitMe.Title,
                        Events          = submitMe.Events.Select(d => d.ID).ToList(),
                        ExternalAddress = submitMe.ExternalAddress,
                        InternalSecret  = submitMe.InternalSecret
                    };

                    var serializedObject = JsonConvert.SerializeObject(viewModelSubmit);

                    HttpContent content  = new StringContent(serializedObject, Encoding.UTF8, "application/json");
                    var         response = await client.PostAsync(GlobalVars.UserEventListURL + "/u", content);

                    var responseStringContents = await response.Content.ReadAsStringAsync();

                    if (!string.IsNullOrEmpty(responseStringContents))
                    {
                        try
                        {
                            var responseUserEventListReturnModel = JsonConvert.DeserializeObject <UserEventListReturnModel>(responseStringContents);
                            var responseUserEventList            = new UserEventList
                            {
                                ID              = submitMe.ID,
                                Events          = submitMe.Events,
                                ExternalAddress = responseUserEventListReturnModel.ExternalAddress,
                                InternalSecret  = responseUserEventListReturnModel.InternalSecret,
                                Title           = submitMe.Title,
                                HasEventListChangedSinceSync = false
                            };
                            return(responseUserEventList);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            return(null);
        }
コード例 #4
0
 public async Task <UserEventList> GetUserEventListWithChildrenAsync(UserEventList list)
 {
     return(await database.GetWithChildrenAsync <UserEventList>(list.ID));
 }
コード例 #5
0
 public async Task DeleteUserEventList(UserEventList value)
 {
     await database.DeleteAsync(value);
 }
コード例 #6
0
 public async Task SetUserEventList(UserEventList value)
 {
     await database.InsertOrReplaceAsync(value);
 }
コード例 #7
0
 public async Task <UserEventList> UpdateUserEventListWithChildrenAsync(UserEventList list)
 {
     return(await UpdateUserEventList(list, true));
 }
コード例 #8
0
 public async Task <UserEventList> InsertUpdateUserEventListAsync(UserEventList submitList)
 {
     return(await restService.InsertUpdateUserEventListAsync(submitList));
 }