public async Task <IActionResult> InsertCategory([FromForm] CategoryInsertModel model) { //var file = model.File; //var uploadResult = new ImageUploadResult(); //if (file.Length > 0) //{ // using (var stream = file.OpenReadStream()) // { // var uploadParams = new ImageUploadParams() // { // File = new FileDescription(file.Name, stream), // Transformation = new Transformation() // .Width(500).Height(500).Crop("fill").Gravity("face") // }; // uploadResult = _cloudinary.Upload(uploadParams); // } //} //model.PhotoUrl = uploadResult.Uri.ToString(); //model.PublicId = uploadResult.PublicId; var insertValue = mapper.Map <Category>(model); var result = await categoryManager.Insert(insertValue); return(Ok(result)); }
public async Task <int> AddCategory(CategoryInsertModel categoryInsertModel) { try { return(await _connection.GetConnection.ExecuteAsync( sql : @"[Menu].[USP_InsertCategory]", param : categoryInsertModel, commandType : CommandType.StoredProcedure )); } catch (Exception exception) { throw exception; } finally { _connection.Dispose(); } }
private async void submitButton_Click(object sender, EventArgs e) { try { CategoryInsertModel category = new CategoryInsertModel { Title = txtTitle.Text }; var addedCategory = await _categoryService.Post <CategoryDto>(category); var subcategoriesToAdd = new List <SubcategoryInsertModel>(); for (int i = 0; i < dataGridSubategories.Rows.Count; i++) { if (i != dataGridSubategories.Rows.Count - 1) { var row = dataGridSubategories.Rows[i] as DataGridViewRow; var cell = row.Cells[0]; subcategoriesToAdd.Add(new SubcategoryInsertModel { Title = cell.Value.ToString(), CategoryId = addedCategory.Id }); } } foreach (var item in subcategoriesToAdd) { await _subCategoryService.Post <dynamic>(item); } Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <int> AddCategory(CategoryInsertModel categoryInsertModel) { return(await _menuItemReporitory.AddCategory(categoryInsertModel)); }
public async Task <IHttpActionResult> AddCategory([FromBody] CategoryInsertModel categoryInsertModel) { return(Ok(await _menuItemService.AddCategory(categoryInsertModel))); }
public IActionResult Insert(CategoryInsertModel category) { return(Ok(_categoryService.Insert(category))); }