private async Task GetExtrasIsExistAndFillForm() { var editMOdelString = Intent.GetStringExtra(ExtrasKeys.ADVERTISEMENT_ITEM_EDIT_MODEL); if (String.IsNullOrEmpty(editMOdelString)) { //not edit return; } Title = "Edycja og³oszenia"; this.editModel = JsonConvert.DeserializeObject <AdvertisementEditModel>(editMOdelString); categoryInfoModel = editModel.CategoryInfoModel; textViewChodesdCategory.Text = categoryInfoModel.Name; advertisementTitle.Text = editModel.Title; advertisementDescription.Text = editModel.Description; advertisementPrice.Text = editModel.Price.ToString(); size = editModel.Size; textViewChodesdSize.Text = editModel.Size.GetDisplayName(); rdBtnOnlyForSell.Selected = editModel.IsOnlyForSell; photosPaths = editModel.PhotosPaths; for (int i = 0; i < photosPaths.Count; i++) { var photoNr = i + 1; await SetPhoto(photoNr); } }
public async Task <IActionResult> Post([FromBody] CategoryInfoModel model) { var categoryId = await ControllerServices.CreateNewCategory(model); _logger.LogInformation("New category created with id {categoryId}", categoryId); return(CreatedAtAction(nameof(Get), new { id = categoryId }, categoryId)); }
public async Task UpdateCategoryInfo(Guid categoryId, CategoryInfoModel model) { var url = UrlBuilder.UpdateCategoryInfoUrl(categoryId); var response = await Client.PutAsJsonAsync(url, model); if (!response.IsSuccessStatusCode) { throw new ApplicationException($"Update category {categoryId} call ended with status code {response.StatusCode}"); } }
public async Task CreateCategory(CategoryInfoModel model) { var url = UrlBuilder.CreateCategoryUrl(); var response = await Client.PostAsJsonAsync(url, model); if (!response.IsSuccessStatusCode) { throw new ApplicationException($"Create new category call ended with status code {response.StatusCode}"); } }
public async Task UpdateCategoryInfo(Guid categoryId, CategoryInfoModel model) { await Commands.UpdateCategoryInfo( categoryId, model.Code, model.Name, model.Url, model.Description, model.IsVisible, model.VisibleFrom, model.VisibleTo); }
public async Task <Guid> CreateNewCategory(CategoryInfoModel model) { var categoryId = await Commands.CreateNewCategory( model.Code, model.Name, model.Url, model.Description, model.IsVisible, model.VisibleFrom, model.VisibleTo); return(categoryId); }
async Task CreateNewCategory(CategoryInfoModel newCategory) { try { await Client.CreateCategory(newCategory); Navigation.NavigateTo("catalog/categories"); } catch { errorRaised = true; } }
public async Task <IActionResult> Put(Guid id, [FromBody] CategoryInfoModel model) { if (id == Guid.Empty) { _logger.LogError("Empty category id"); return(BadRequest(nameof(id))); } await ControllerServices.UpdateCategoryInfo(id, model); _logger.LogInformation("Info updated for category with {categoryId}", id); return(Ok()); }
async Task UpdateCategoryInfo(CategoryInfoModel model) { try { await Client.UpdateCategoryInfo(_CategoryId, model); } catch { errorRaised = true; } finally { StateHasChanged(); } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.bitmapOperationService = new BitmapOperationService(); this.advertisementItemService = new AdvertisementItemService(bearerToken); this.gpsLocationService = new GpsLocationService(this, null); this.categoriesSelectingHelper = new CategoriesSelectingHelper(this, bearerToken); this.sizeSelectingHelper = new SizeSelectingHelper(this); this.categoryInfoModel = new CategoryInfoModel(); SetContentView(Resource.Layout.AddNewAdvertisementActivity); base.SetupToolbar(); SetupViews(); photosPaths = new List <string>(); tempPhotosPaths = new List <string>(); await GetExtrasIsExistAndFillForm(); }
protected override Task OnInitializedAsync() { context = new EditContext(Model); editingEnabled = !Readonly; _originalModel = new CategoryInfoModel { Code = Model.Code, Description = Model.Description, IsVisible = Model.IsVisible, Name = Model.Name, Url = Model.Url, VisibleFrom = Model.VisibleFrom, VisibleTo = Model.VisibleTo }; return(base.OnInitializedAsync()); }
public CategoryDetailModel GetCategoryDetail(Guid categoryId) { var category = Database.Categories .Include(c => c.Parent) .Include(c => c.Children) .SingleOrDefault(c => c.Id == categoryId); if (category is null) { return(null); } var model = new CategoryDetailModel { Id = categoryId, Details = new CategoryInfoModel { Code = category.Code, Description = category.Description, IsVisible = category.IsVisible, Name = category.Name, Url = category.Url, VisibleFrom = category.VisibleFrom, VisibleTo = category.VisibleTo }, Seo = category.Seo, Parent = category.Parent is null ? new CategoryDescriptorModel() : new CategoryDescriptorModel { Id = category.Parent.Id, Code = category.Parent.Code, Name = category.Parent.Name }, Children = category.Children.Select(c => new CategoryDescriptorModel { Id = c.Id, Code = c.Code, Name = c.Name }).ToList() }; return(model); }
void Cancel() { Model = new CategoryInfoModel { Code = _originalModel.Code, Description = _originalModel.Description, IsVisible = _originalModel.IsVisible, Name = _originalModel.Name, Url = _originalModel.Url, VisibleFrom = _originalModel.VisibleFrom, VisibleTo = _originalModel.VisibleTo }; if (Readonly) { editingEnabled = false; } StateHasChanged(); }