//Save Category private void SaveButton_Click(object sender, EventArgs e) { category.Name = nameTextBox.Text; category.ErrorText = categoryErrorLabel.Text; bool isExist = categoryManagement.IsExisted(category); if (isExist) { categoryErrorLabel.Text = "*This Categerory Already Existed!!"; return; } categoryErrorLabel.Text = ""; bool verify = categoryManagement.IsVerified(category); if (verify) { categoryErrorLabel.Text = "*Field Must Not Be Empty!!"; return; } bool isAdd = categoryManagement.IsAdded(category); if (isAdd) { nameTextBox.Clear(); categoryErrorLabel.Text = ""; DataTable dt = new DataTable(); dt = categoryRepository.AddCategory(); categoryDataGridView.DataSource = dt; } }
public JsonResult Create(CreateForm form) { CreateModel model = new CreateModel(); bool isError = false; if (string.IsNullOrWhiteSpace(form.Category)) { isError = true; model.CategoryError = "Введите название категории"; } if (_categoryRepository.Get(form.Category) != null) { isError = true; model.CategoryError = "Такая категория уже есть"; } model.CategoryValue = form.Category; if (!isError) { _categoryRepository.AddCategory(new СategoryEntity { Category = form.Category }); } return(Json(new { IsSuccess = true })); }
public IActionResult Index(int?id, CategoryViewModel categoryViewModel) { Category category = categoryViewModel.category; if (id == null || id == 0) { CategoryRepository.AddCategory(category); } else { CategoryRepository.UpdateCategory(category); } IEnumerable <Category> categories = CategoryRepository.GetAllCategory(); categoryViewModel.categories = categories; if (id == null || id == 0) { return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", new { id = 0 })); } }
public ActionResult SaveCategory(Category category) { if (!ModelState.IsValid) { return(Json(new { isValid = false, message = "fail to save" }, JsonRequestBehavior.AllowGet)); } if (category.CategoryID == 0) { _categoryRepository.AddCategory(category); return(Json(new { isValid = true, message = "Saved Succesfully" }, JsonRequestBehavior.AllowGet)); } if (_categoryRepository.UpdateCategory(category)) { return(Json(new { isValid = true, message = "Update Succesfully" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { isValid = false, message = "Update failed" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddCategory(CategoryViewModel AC) { CategoryRepository AddC = new CategoryRepository(); AddC.AddCategory(AC); return(RedirectToAction("Category")); }
public ActionResult Add(Category b) { CategoryRepository _AddRepository = new CategoryRepository(); _AddRepository.AddCategory(b); List <Category> bookList = new List <Category>(); bookList = _AddRepository.GetAllCategory(); return(View("ListView", bookList)); }
public async Task <ActionResult <Category> > PostCategory(Category cat) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var dbCat = await _repo.AddCategory(cat); return(CreatedAtAction("GetCategory", new { id = dbCat.Id }, dbCat)); }
public void AddCategoryDetails() { Console.Write("Enter Category Id: "); int id = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter Category Name: "); string name = Console.ReadLine(); categoryRepo.AddCategory(id, name); }
public ZonaFl.Persistence.Entities.Category InsertCategory(string categoryName) { CategoryRepository caterepo = new CategoryRepository(); ZonaFl.Persistence.Entities.Category category = new Persistence.Entities.Category() { Name = categoryName }; return(caterepo.AddCategory(category)); }
private void FirstStart() { ModelContainer cont = new ModelContainer(); BranchRepository branchRepository = new BranchRepository(cont); CategoryRepository categoryRepository = new CategoryRepository(cont); CompanyOwnerRepository companyOwnerRepository = new CompanyOwnerRepository(cont); PersonRepository personRepository = new PersonRepository(cont); PositionRepository positionRepository = new PositionRepository(cont); RoomRepository roomRepository = new RoomRepository(cont); TableRepository tableRepository = new TableRepository(cont); ClientRepository clientRepository = new ClientRepository(cont); if (positionRepository.Positions().Count() == 0) { positionRepository.AddPosition("Суперпользователь", true, true, true, true, true, true); } CompanyOwner co = new CompanyOwner(); if (personRepository.Persones().Count() == 0) { co = companyOwnerRepository.AddCompanyOwner("Суперпользователь", "", "", "", "", "super", "super".GetHashCode().ToString(), "", "", "", positionRepository.GetPositionByName("Суперпользователь")); } Branch b = new Branch(); if (branchRepository.Branches().Count() == 0) { b = branchRepository.AddBranch("", "", DateTime.Now, DateTime.Now, "", "", "", "", "", co, null); } Room r = new Room(); if (roomRepository.Rooms().Count() == 0) { r = roomRepository.AddRoom("", b); } if (categoryRepository.Categotyes().Count() == 0) { categoryRepository.AddCategory(""); } if (tableRepository.Tables().Count() == 0) { tableRepository.AddTable(1, "", r); } if (clientRepository.Clients().Count() == 0) { clientRepository.AddClient("Клиент", "", "", "", "", "", "", "", "", "", "", ""); } }
public ActionResult Create(Category category) { try { _categoryRepository.AddCategory(category); return(RedirectToAction(nameof(Index))); } catch { return(View(category)); } }
public void AddCategory() { Categories category = new Categories(); category.CategoryName = "Hrana"; category.Description = " voce i povrce"; category.Picture = GetPhoto(@"C:\Users\vlada.milosavljevic\Pictures\hrana.jpg"); CategoryRepository rep = new CategoryRepository(); int id = rep.AddCategory(category); Assert.IsNotNull(id > 0); }
public void AddCategoryDetails() { Console.Write("Enter Category Id: "); int id = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter Category Name: "); string name = Console.ReadLine(); DateTime created_at = DateTime.Now; categoryRepo.AddCategory(id, name, created_at); }
public ActionResult AddCategory(AddCategoryModel model) { if (categoryRepository.AddCategory(model.Name, model.Description)) { return(RedirectToAction("category", "Admin")); } else { ModelState.AddModelError("", "Сталась помилка"); return(View()); } }
private void AddButton_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(textBoxNewCategoryName.Text) && !textBoxNewCategoryName.Text.Equals("enter new category/category name name here")) { var newCategory = new Category(textBoxNewCategoryName.Text); _categoryRepository.AddCategory(newCategory); LocalAppData.Instance.Categories.Add(newCategory); PrepareForm(); } }
public void CanInsertCategory() { Category categoryToInsert = new Category(); var repo = new CategoryRepository(); categoryToInsert.CategoryId = 6; categoryToInsert.CategoryName = "Florbies"; repo.AddCategory(categoryToInsert); Assert.AreEqual(6, categoryToInsert.CategoryId); Assert.AreEqual("Florbies", categoryToInsert.CategoryName); }
public IHttpActionResult AddCategory(List <string> content) { try { var helper = new CategoryRepository(); helper.AddCategory(content[0]); return(Ok()); } catch { return(BadRequest()); } }
public void AddCategory(AddCategoryViewModel model) { var category = new Category() { Name = model.Name, Id = model.Id, SubCategory = new SubCategory() { Name = model.Name } }; _categoryRepository.AddCategory(category); }
public void AddCategory_Success() { using (var context = new MMTContext(this.dbContextOptions)) { // Arrange var categoryRep = new CategoryRepository(context); var category = new Category("Test", 60000, 70000, true); // Act var result = categoryRep.AddCategory(category); // Assert Assert.AreEqual(category.Id, result.Id); } }
public ActionResult CreateCategory([Bind(Include = "CategoryID,CategoryType,FoodName,Price,FoodImg")] Categories category, HttpPostedFileBase UserPhoto) { if (ModelState.IsValid) { try { // Set the extension only accept these var extension = new[] { ".jpg", ".png", ".jpeg", ".Jpg" }; // If you have uploaded a photo, it will go inside here if (UserPhoto != null) { // Get the file extension var ext = Path.GetExtension(UserPhoto.FileName); // If the file contains which extension are set, it will go in here if (extension.Contains(ext)) { // So my database FoodImg will save the content category.FoodImg = new byte[UserPhoto.ContentLength]; UserPhoto.InputStream.Read(category.FoodImg, 0, UserPhoto.ContentLength); } else { throw new Exception("Only accept jpg,png,jpeg. Please upload again."); } ViewbagSuccess("New User Created Successful."); Category.AddCategory(category); return(View()); } else { throw new Exception("Please upload your img"); } } catch (Exception lol) { ViewbagError(lol.Message); } } return(View(category)); }
public void AddOrUpdate(CategoryDTO categoryDTO) { var category = new Category { Id = categoryDTO.Id != Guid.Empty ? categoryDTO.Id : Guid.NewGuid(), Name = categoryDTO.Name, }; if (categoryDTO.Id != Guid.Empty) { _repo.UpdateCategory(category); } else { _repo.AddCategory(category); } }
public void OnPost() { CategoryRepository categoryRepo = new CategoryRepository(); Categories = categoryRepo.GetAllRideCategories(); if (!string.IsNullOrWhiteSpace(CategoryName)) { if (!string.IsNullOrWhiteSpace(CategoryDescription)) { RideCategory newCategory = new RideCategory { Name = CategoryName, Description = CategoryDescription }; foreach (RideCategory rideCategory in Categories) { if (rideCategory.Name == newCategory.Name) { NameUsed = true; } } if (!NameUsed) { categoryRepo.AddCategory(newCategory); Message = "Kategori oprettet"; } else { Message = "Kategorinavnet er allerede i brug, og blev derfor ikke oprettet"; } } else { Message = "Beskrivelsen skal have en værdi"; } } else { Message = "Navn skal have en værdi"; } }
public void CanDeleteCategory() { Category categoryToInsert = new Category(); var repo = new CategoryRepository(); categoryToInsert.CategoryId = 6; categoryToInsert.CategoryName = "Florbies"; repo.AddCategory(categoryToInsert); var loaded = repo.GetById(6); Assert.IsNotNull(loaded); repo.DeleteCategory(6); loaded = repo.GetById(6); Assert.IsNull(loaded); }
public void AddOrUpdateCategory(CategoryDTO category) { var cat = new Category { Id = category.Id != Guid.Empty ? category.Id : Guid.NewGuid(), //inline if Name = category.Name }; if (category.Id != Guid.Empty) { //category exists ==> Update _repo.updateCategory(cat); } else { //category does no exist ==> Add _repo.AddCategory(cat); } }
public void AddOrUpdate(CategoryDTO category) { if (category.Id == Guid.Empty) { var newCategory = new Category { Id = new Guid(), Name = category.Name }; _categoryRepo.AddCategory(newCategory); } else { var updatedCategory = new Category { Id = category.Id, Name = category.Name }; _categoryRepo.UpdateCategory(updatedCategory); } }
protected void btnAddCategory_Click(object sender, EventArgs e) { _repository.AddCategory(txtCategoryName.Text.Replace("--", "")); DisplayData(); }
public void Create(AddCategoryCommand newCategory) { var repo = new CategoryRepository(); repo.AddCategory(newCategory); }
public ActionResult Add(Category category) { repository.AddCategory(category); return(RedirectToAction("Index")); }
public bool AddCategory(Category category) { return(_categoryRepository.AddCategory(category)); }
internal bool AddCategory(Category _category) { return(_categoryRepository.AddCategory(_category)); }