public CategoryAdd Add(CategoryAdd category) { if (category is null) { throw new ArgumentNullException(ApiResponses.CannotAddNullCategory, innerException: null); } if (string.IsNullOrEmpty(category.Name)) { throw new ArgumentNullException(ApiResponses.CannotAddCategoryWithNameNullOrEmpty, innerException: null); } var mappedCategory = _mapper.Map <CategoryDb>(category); if (category.WebsitesIds is not null) { var websiteDetailsList = _categoriesUnitOfWork.WebsiteDetails .Get(n => category.WebsitesIds.Contains(n.id)).ToList(); mappedCategory.Websites = websiteDetailsList; } _categoriesUnitOfWork.Categories.Insert(mappedCategory); _categoriesUnitOfWork.Commit(); _mapper.Map(mappedCategory, category); return(category); }
private void btnAddCategory_Click(object sender, EventArgs e) { CategoryAdd categoriesForm = new CategoryAdd(); openChildForm(categoriesForm); //pnlButtons.Hide(); }
private void productSaveBtn_Click(object sender, EventArgs e) { rowcount = 0; CategoryAdd aCategory = new CategoryAdd(); aCategory.Category = categoryTextBox.Text; categoryTextBox.Text = ""; categoryTextBox.Clear(); categoryTextBox.Focus(); if (categorySaveBtn.Text == "Save") { string message = aCategoryManager.SaveCategory(aCategory); MessageBox.Show(message); } else { aCategory.Id = Convert.ToInt32(hiddenIdLevel.Text); string message = aCategoryManager.UpdateCategory(aCategory); MessageBox.Show(message); } PopulateCategoryListView(); }
private void ItemEntryUI_Load(object sender, EventArgs e) { //Product CategoryAdd defaultCategory = new CategoryAdd(); defaultCategory.Id = -1; defaultCategory.Category = "--Select--"; List <CategoryAdd> categories = aCategoryManager.GetAllCategory(); categories.Insert(0, defaultCategory); itemCategoryComboBox.DataSource = categories; itemCategoryComboBox.DisplayMember = "Category"; itemCategoryComboBox.ValueMember = "Id"; // Company CompanyAdd defaultCompany = new CompanyAdd(); defaultCompany.Id = -1; defaultCompany.CompanyName = "--Select--"; List <CompanyAdd> companies = aCompanyManager.GetAllCompanies(); companies.Insert(0, defaultCompany); itemCompanyNameComboBox.DataSource = companies; itemCompanyNameComboBox.DisplayMember = "CompanyName"; itemCompanyNameComboBox.ValueMember = "Id"; }
public static CategoryDb Map(this CategoryAdd category) { return(new CategoryDb { Id = category.Id, Name = category.Name }); }
public void should_throw_exception_when_category_is_null() { CategoryAdd category = null; _sut.Invoking(n => n.Add(category)) .Should() .Throw <ArgumentNullException>() .WithMessage(ApiResponses.CannotAddNullCategory); }
public string UpdateCategory(CategoryAdd category) { int rowaffected = aCategoryGateway.UpdateCategory(category); if (rowaffected > 0) { return("Update successfully."); } return("Update failed."); }
// Post: Admin/Category/Add/id public virtual ActionResult Add(CategoryAdd model) { if (!ModelState.IsValid) { return(View(model)); } _categoryService.Add(model); _uow.SaveAllChanges(); return(RedirectToAction("Index")); }
public int SaveProduct(CategoryAdd aProduct) { connection.Open(); query = "INSERT INTO Category (CategoryName) VALUES (@CategoryName)"; cmd = new SqlCommand(query, connection); cmd.Parameters.Clear(); cmd.Parameters.Add("CategoryName", SqlDbType.NVarChar); cmd.Parameters["CategoryName"].Value = aProduct.Category; int rowAffected = cmd.ExecuteNonQuery(); connection.Close(); return(rowAffected); }
private void categoryListView_DoubleClick(object sender, EventArgs e) { ListViewItem selectedItem = categoryListView.SelectedItems[0]; CategoryAdd category = selectedItem.Tag as CategoryAdd; if (category != null) { categoryTextBox.Text = category.Category; hiddenIdLevel.Text = category.Id.ToString(); categorySaveBtn.Text = "Update"; } }
public async Task <dynamic> Add([FromBody] CategoryAdd item) { if (item == null) { return new { JsonString = "Error" } } ; var currentUser = JwtIdentity.UserInfo(Thread.CurrentPrincipal.Identity); //item.SubmiterUserId = currentUser.Id; var result = await _sqlData.Category.Add(item); return(new { Result = JsonConvert.DeserializeObject(result) }); }
public string SaveCategory(CategoryAdd aCategory) { if (aCategoryGateway.IsNameExist(aCategory.Category)) { return("Category Name Already Exists."); } int rowaffected = aCategoryGateway.SaveProduct(aCategory); if (rowaffected > 0) { return("Save Successfully."); } return("Save Failed."); }
public int UpdateCategory(CategoryAdd aCategory) { query = "UPDATE Category SET CategoryName = @CategoryName WHERE Id = @Id"; cmd = new SqlCommand(query, connection); cmd.Parameters.Clear(); cmd.Parameters.Add("CategoryName", SqlDbType.NVarChar); cmd.Parameters["CategoryName"].Value = aCategory.Category; cmd.Parameters.Add("Id", SqlDbType.Int); cmd.Parameters["Id"].Value = aCategory.Id; connection.Open(); int rowAffected = cmd.ExecuteNonQuery(); connection.Close(); return(rowAffected); }
public async void Edit_Catagory() { try { if (SelectedCatagory.CATAGORY_ID != null && SelectedCatagory.CATAGORY_ID != 0) { data = null; App.Current.Properties["Action"] = "Edit"; HttpClient client = new HttpClient(); client.BaseAddress = new Uri(GlobalData.gblApiAdress); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); client.Timeout = new TimeSpan(500000000000); HttpResponseMessage response = client.GetAsync("api/CatagoryAPI/CatagoryEdit?id=" + SelectedCatagory.CATAGORY_ID + "").Result; if (response.StatusCode.ToString() == "OK") { data = JsonConvert.DeserializeObject <CategoryModel[]>(await response.Content.ReadAsStringAsync()); if (data.Length > 0) { for (int i = 0; i < data.Length; i++) { SelectedCatagory.BAR_CODE_PREFIX = data[i].BAR_CODE_PREFIX; SelectedCatagory.CATAGORY_DEC = data[i].CATAGORY_DEC; SelectedCatagory.CATAGORY_ID = data[i].CATAGORY_ID; SelectedCatagory.CATAGORY_NAME = data[i].CATAGORY_NAME; SelectedCatagory.COMPANY_ID = data[i].COMPANY_ID; SelectedCatagory.DISPLAY_INDEX = data[i].DISPLAY_INDEX; SelectedCatagory.IS_DELETE = data[i].IS_DELETE; SelectedCatagory.IS_NOT_PROTAL = data[i].IS_NOT_PROTAL; } App.Current.Properties["CatagoryEdit"] = SelectedCatagory; CategoryAdd _CategoryAdd = new CategoryAdd(); _CategoryAdd.Show(); } } } else { MessageBox.Show("Select Catagory first", "Item Selection", MessageBoxButton.OK, MessageBoxImage.Error); return; } } catch (Exception ex) { throw; } }
public List <CategoryAdd> GetAllCategory() { connection.ConnectionString = connectionString; cmd = new SqlCommand(); cmd.CommandText = "SELECT * FROM Category"; cmd.Connection = connection; connection.Open(); reader = cmd.ExecuteReader(); List <CategoryAdd> categoy = new List <CategoryAdd>(); while (reader.Read()) { CategoryAdd category = new CategoryAdd(); category.Id = (int)reader["Id"]; category.Category = reader["CategoryName"].ToString(); categoy.Add(category); } reader.Close(); connection.Close(); return(categoy); }
public void CallStateCategoryAdd(StateSaveCategory category) => CategoryAdd?.Invoke(category);
private void button1_Click(object sender, EventArgs e) { CategoryAdd categoryAddView = new CategoryAdd(); categoryAddView.Show(); }
// GET: Admin/Category/Add public virtual ActionResult Add() { CategoryAdd Category = new CategoryAdd(); return(View(Category)); }
public ActionResult <CategoryAdd> Add(CategoryAdd category) { var addedCategory = _categoriesService.Add(category); return(addedCategory); }
public void AddCategory_Click() { CategoryAdd _CategoryAdd = new CategoryAdd(); _CategoryAdd.Show(); }
public void Add(CategoryAdd category) { _categories.Add(new Category { Title = category.Title, Description = category.Description, Slug = category.Slug, Order = category.Order }); }