public ApiCategory Add(ApiCategory apiCategory)
        {
            db.Categories.Add(Mapper.Map <ApiCategory, Category>(apiCategory));
            apiCategory.CatID = db.SaveChanges();

            return(apiCategory);
        }
        public async Task <IActionResult> EditCategory([FromBody] ApiCategory model)
        {
            var category = await _uow.Categories.GetByIdAsync(model.Id);

            category.Name         = model.Name;
            category.Colour       = model.Colour;
            category.Type         = model.Type;
            category.Recurring    = model.Recurring;
            category.DateModified = DateTime.UtcNow;

            if (category.Recurring)
            {
                category.RecurringDate  = model.RecurringDate;
                category.RecurringValue = model.RecurringValue;
            }
            else
            {
                category.RecurringDate  = null;
                category.RecurringValue = null;
            }

            _uow.Categories.Update(category);
            await _uow.CommitAsync();

            model = _mapper.Map <Category, ApiCategory>(category);

            return(new JsonResult(model));
        }
        public async Task <IActionResult> AddCategory([FromBody] ApiCategory model)
        {
            var category = new Category
            {
                UserId    = Token.UserId,
                Name      = model.Name,
                Colour    = model.Colour,
                Type      = model.Type,
                Recurring = model.Recurring,
                DateAdded = DateTime.UtcNow
            };

            if (category.Recurring)
            {
                category.RecurringDate  = model.RecurringDate;
                category.RecurringValue = model.RecurringValue;
            }

            _uow.Categories.Add(category);
            await _uow.CommitAsync();

            model = _mapper.Map <Category, ApiCategory>(category);

            return(new JsonResult(model));
        }
        static void Main(string[] args)
        {
            var result = ApiCategory.GetList("4c9a7827-8028-4236-a798-e5ac155bc070",
                                             "3518486",
                                             "0K024PEUxUI",
                                             0);

            Console.Read();
        }
Beispiel #5
0
 public int Add(ApiCategory it)
 {
     using (var context = _di.GetService <ApplicationDbContext>())
     {
         it.IsActive = true;
         var category = _mapper.Map <Category>(it);
         context.Categories.Add(category);
         context.SaveChanges();
         return(category.Id);
     }
 }
Beispiel #6
0
 public void Update(ApiCategory it)
 {
     using (var context = _di.GetService <ApplicationDbContext>())
     {
         var real = context.Categories.Find(it.Id);
         if (real != null)
         {
             real.Name = it.Name;
         }
         context.SaveChanges();
     }
 }
 public ApiCategory Post([FromBody] ApiCategory apiCategorie)
 {
     try
     {
         apiCategorie = service.Add(apiCategorie);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(apiCategorie);
 }
            public static string Build(ApiCategory apiCategory)
            {
                string name = apiCategory.ToString();

                if (apiCategory != ApiCategory.editorextensions)
                {
                    return(MAIN + "PlayFabUnity" + char.ToUpper(name[0]) + name.Substring(1) + ".git");
                }
                else
                {
                    return(MAIN + "PlayFabUnityEditorExtensions.git");
                }
            }
 public ApiCategory Put([FromBody] ApiCategory apiCategorie)
 {
     try
     {
         int?id = apiCategorie.CatID;
         apiCategorie = service.Update(id, apiCategorie);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(apiCategorie);
 }
        public ApiCategory Update(int?id, ApiCategory apiCategory)
        {
            var categoryInDB = db.Categories.Where(c => c.CatID == id).FirstOrDefault();

            if (categoryInDB != null)
            {
                apiCategory.CatID            = categoryInDB.CatID;
                categoryInDB                 = Mapper.Map <ApiCategory, Category>(apiCategory);
                db.Entry(categoryInDB).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }

            return(apiCategory);
        }
        public ApiCategory GetSingle(int?id)
        {
            ApiCategory apiCategory = new ApiCategory();

            try
            {
                apiCategory = service.GetSingle(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(apiCategory);
        }
        public static string GetApiVersion(ApiCategory apiCategory)
        {
            var packageJson = (TextAsset)AssetDatabase.LoadAssetAtPath(Path.Combine(Strings.Package.BuildPath(apiCategory), "package.json"),
                                                                       typeof(TextAsset));

            if (packageJson != null)
            {
                return(PlayFabSimpleJson.DeserializeObject <Dictionary <string, string> >(packageJson.text)["version"]);
            }
            else
            {
                return(null);
            }
        }
Beispiel #13
0
        public async Task <IActionResult> EditCategory([FromBody] ApiCategory model)
        {
            var category = await _uow.Categories.GetByIdAsync(model.Id);

            category.Name         = model.Name;
            category.Type         = model.Type;
            category.ColourHex    = model.ColourHex;
            category.DateModified = DateTime.UtcNow;

            _uow.Categories.Update(category);
            await _uow.CommitAsync();

            model = _mapper.Map <Category, ApiCategory>(category);

            return(new JsonResult(model));
        }
 public ActionResult CategoryList()
 {
     try
     {
         var token        = GetProductUserToken();
         var categoryList = ApiCategory.GetList(token.AccessToken,
                                                AppConfigBll.AppConfig.AppKey,
                                                AppConfigBll.AppConfig.AppSecrect,
                                                0);
         return(Json(categoryList));
     }
     catch (Exception ex)
     {
         RPoney.Log.LoggerManager.Error(GetType().Name, "", ex);
         return(new EmptyResult());
     }
 }
Beispiel #15
0
        public async Task <IActionResult> AddCategory([FromBody] ApiCategory model)
        {
            var category = new Category
            {
                UserId    = Token.UserId,
                Name      = model.Name,
                Type      = model.Type,
                ColourHex = model.ColourHex,
                DateAdded = DateTime.UtcNow
            };

            _uow.Categories.Add(category);
            await _uow.CommitAsync();

            model = _mapper.Map <Category, ApiCategory>(category);

            return(new JsonResult(model));
        }
        /// <summary>
        /// Registers commands for UI elements
        /// </summary>
        private void RegisterCommands()
        {
            // Handle item click
            ItemClickCommand = new Command((p) =>
            {
                var item     = p as ApiItem;
                var category = new ApiCategory()
                {
                    Id = item.CategoryId
                };

                // Navigate to edit
                NavigationHelper.Navigate(typeof(NewItemPage),
                                          new EditItemPageParams()
                {
                    Category = category,
                    Item     = item
                });
            });

            // Handle setting favorites
            SetFavoriteCommand = new Command(SetFavoriteCommandHandler);
        }
Beispiel #17
0
        /// <summary>
        /// Registers commands for UI elements
        /// </summary>
        private void RegisterCommands()
        {
            // Handle add category
            AddCategoryCommand = new Command(async(p) =>
            {
                // Prompt for name
                await DialogHelper.ShowClosableDialog <NamePromptDialog>(async(d) =>
                {
                    try
                    {
                        //create new category
                        var category = new ApiCategory()
                        {
                            Name  = d.Value,
                            Items = new ApiItem[] { }
                        };

                        // Send the category to the api
                        var resp = await KryptPadApi.SaveCategoryAsync(category);

                        // Set the id of the newly created category
                        category.Id = resp.Id;

                        // Add the category to the list
                        Categories.Add(category);

                        // Add view to the ItemsView object
                        ItemsView.Source = Categories;

                        // Refresh
                        OnPropertyChanged(nameof(ItemsView));

                        // Hide empty message
                        EmptyMessageVisibility = Visibility.Collapsed;
                    }
                    catch (WebException ex)
                    {
                        // Something went wrong in the api
                        await DialogHelper.ShowMessageDialogAsync(ex.Message);
                    }
                    catch (Exception ex)
                    {
                        // Failed
                        await DialogHelper.ShowGenericErrorDialogAsync(ex);
                    }
                }, "Add Category");
            });

            // Handle add new item
            AddItemCommand = new Command(AddItemCommandHandler);

            // Handle item click
            ItemClickCommand = new Command((p) =>
            {
                var item     = p as ApiItem;
                var category = (from c in Categories
                                where c.Items.Contains(item)
                                select c).FirstOrDefault();

                // Navigate to edit
                NavigationHelper.Navigate(typeof(NewItemPage),
                                          new EditItemPageParams()
                {
                    Category = category,
                    Item     = item
                });
            });

            // Handle change passphrase command
            ChangePassphraseCommand = new Command(async(p) =>
            {
                var dialog = new ChangePassphraseDialog();

                await dialog.ShowAsync();
            });

            // Handle rename command
            RenameProfileCommand = new Command(async(p) =>
            {
                // Prompt for name
                await DialogHelper.GetValueAsync(async(d) =>
                {
                    try
                    {
                        // Set new name
                        var profile  = KryptPadApi.CurrentProfile;
                        profile.Name = d.Value;

                        // Send the category to the api
                        var resp = await KryptPadApi.SaveProfileAsync(profile);
                    }
                    catch (WebException ex)
                    {
                        // Something went wrong in the api
                        await DialogHelper.ShowMessageDialogAsync(ex.Message);
                    }
                    catch (Exception ex)
                    {
                        // Failed
                        await DialogHelper.ShowGenericErrorDialogAsync(ex);
                    }
                }, "RENAME PROFILE", KryptPadApi.CurrentProfile.Name);
            });

            // Handle delete command
            DeleteProfileCommand = new Command(async(p) =>
            {
                var res = await DialogHelper.Confirm(
                    "All of your data in this profile will be deleted permanently. THIS ACTION CANNOT BE UNDONE. Are you sure you want to delete this entire profile?",
                    "WARNING - CONFIRM DELETE",
                    async(ap) =>
                {
                    try
                    {
                        // Delete the selected profile
                        await KryptPadApi.DeleteProfileAsync(KryptPadApi.CurrentProfile);

                        // Navigate back to the profiles list
                        NavigationHelper.Navigate(typeof(SelectProfilePage), null);
                    }
                    catch (WebException ex)
                    {
                        // Something went wrong in the api
                        await DialogHelper.ShowMessageDialogAsync(ex.Message);
                    }
                    catch (Exception ex)
                    {
                        // Failed
                        await DialogHelper.ShowGenericErrorDialogAsync(ex);
                    }
                }
                    );
            });

            // Download profile handler
            DownloadProfileCommand = new Command(async(prop) =>
            {
                try
                {
                    // Prompt for a place to save the file
                    var sfd = new FileSavePicker()
                    {
                        SuggestedFileName = KryptPadApi.CurrentProfile.Name,
                    };

                    //sfd.FileTypeChoices.Add("KryptPad Document Format", new List<string>(new[] { ".kdf" }));
                    sfd.FileTypeChoices.Add("KryptPad Document Format", new[] { ".kdf" });

                    // Show the picker
                    var file = await sfd.PickSaveFileAsync();

                    if (file != null)
                    {
                        // Get profile
                        var profileData = await KryptPadApi.DownloadCurrentProfileAsync();

                        // Save profile to file
                        using (var fs = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite))
                            using (var sw = new StreamWriter(fs.AsStreamForWrite()))
                            {
                                // Write the data
                                sw.Write(profileData);
                            }

                        await DialogHelper.ShowMessageDialogAsync("Profile downloaded successfully");
                    }
                }
                catch (WebException ex)
                {
                    // Something went wrong in the api
                    await DialogHelper.ShowMessageDialogAsync(ex.Message);
                }
                catch (Exception ex)
                {
                    // Failed
                    await DialogHelper.ShowGenericErrorDialogAsync(ex);
                }
            });

            // Handle category rename
            RenameCategoryCommand = new Command(RenameCategoryCommandHandler);

            // Handle category delete
            DeleteCategoryCommand = new Command(DeleteCategoryCommandHandler);

            // Handle selection mode
            SelectModeCommand = new Command(SelectModeCommandHandler);

            // Handle the move command
            MoveItemsCommand = new Command(MoveItemsCommandHandler, CanMoveItems);

            // Handle setting favorites
            SetFavoriteCommand = new Command(SetFavoriteCommandHandler);
        }
 public static string BuildPath(ApiCategory api) => Path.Combine("Packages", BuildName(api));
Beispiel #19
0
 public ApiResponseBase Post([FromBody] ApiCategory product)
 {
     _repo.Update(product);
     return(new ApiResponseBase());
 }
Beispiel #20
0
        /// <summary>
        /// Loads an item into the view model
        /// </summary>
        /// <param name="item"></param>
        public async Task LoadItemAsync(ApiItem selectedItem, ApiCategory category)
        {
            // Prevent change triggers
            _isLoading = true;
            IsBusy     = true;

            try
            {
                // Get list of categories for the combobox control
                var categories = await KryptPadApi.GetCategoriesAsync();

                // Set the category view source for the combobox
                CategoriesView.Source = categories.Categories;

                // Update view
                OnPropertyChanged(nameof(CategoriesView));

                // Set the selected category in the list
                Category = (from c in categories.Categories
                            where c.Id == category.Id
                            select c).SingleOrDefault();

                // Check to make sure our parameters are set
                if (Category == null)
                {
                    // Show error
                    throw new WarningException("The item you are trying to edit does not exist in this category.");
                }

                // Get the item
                var itemResp = await KryptPadApi.GetItemAsync(Category.Id, selectedItem.Id);

                // Get the item
                var item = itemResp.Items.FirstOrDefault();

                // Set item
                Item = item;

                // Set properties
                ItemName      = item.Name;
                Notes         = item.Notes;
                SelectedColor = item.Background;

                // Set fields
                foreach (var field in item.Fields)
                {
                    // Add field to the list
                    AddFieldToCollection(new FieldModel(field));
                }
            }
            catch (WarningException ex)
            {
                // Operation failed
                await DialogHelper.ShowMessageDialogAsync(ex.Message);
            }
            catch (WebException ex)
            {
                // Operation failed
                await DialogHelper.ShowMessageDialogAsync(ex.Message);

                // Navigate back to the items page
                NavigationHelper.Navigate(typeof(ItemsPage), null);
            }
            catch (Exception ex)
            {
                // Failed
                await DialogHelper.ShowGenericErrorDialogAsync(ex);

                // Navigate back to the items page
                NavigationHelper.Navigate(typeof(ItemsPage), null);
            }

            _isLoading = false;
            IsBusy     = false;
        }
Beispiel #21
0
 public ApiResponseBase Put([FromBody] ApiCategory product)
 {
     _repo.Add(product);
     return(new ApiResponseBase());
 }
 public static string BuildName(ApiCategory api) => PREFIX + api.ToString();
 public ApiCategory Add(ApiCategory category)
 {
     return(factory.CategoriesDAO.Add(category));
 }
 public ApiCategory Update(int?id, ApiCategory category)
 {
     return(factory.CategoriesDAO.Update(id, category));
 }