Beispiel #1
0
        public void AddCategory_Performs_Expected_Work()
        {
            SetUp();
            Category category = new Category();

            var expected = sut.AddCategory(category);

            Assert.That(expected, Contains.Item(category));
        }
Beispiel #2
0
    private void CreateCategory(string _title, Texture2D _img, AudioClip _clip, List <string> _cardKeys = null, List <bool> _cardVisibles = null)
    {
        var categoryKey = $"{patientDataManager.GetUserLogin()}{_title}{saveSystem.GetCustomCategoryData().keys.Count}";
        var image1Key   = $"{patientDataManager.GetUserLogin()}{saveSystem.GetCustomCategoryData().keys.Count}image1";
        var audio1Key   = $"{patientDataManager.GetUserLogin()}{saveSystem.GetCustomCategoryData().keys.Count}audio1";

        var size = (_img.height > _img.width) ? _img.width : _img.height;
        var rect = new Rect(0, 0, size, size);

        categoryData = new CategoryData(
            (int)categoryManager.gameName,
            _title,
            Sprite.Create(_img, rect, Vector2.zero),
            _clip,
            true,
            (_cardKeys == null) ? new List <string>() : _cardKeys,
            (_cardVisibles == null) ? new List <bool>() : _cardVisibles,
            true);

        saveSystem.SaveCustomCategoryFromLocal(categoryData, categoryKey, image1Key, audio1Key);

        storage.AddCategoryToBase(categoryData, categoryKey, image1Key, audio1Key);
        categoryManager.AddCategory(categoryKey);
        Reset();
    }
Beispiel #3
0
        private static void PromptAddCategory()
        {
            string name;
            int    parentId = 0;

            Console.Write(@"-----------> Category name: ");
            name = Console.ReadLine();
            Console.Write(@"-----------> Parent Category Id: ");
            try
            {
                parentId = Int32.Parse(Console.ReadLine());
            }
            catch (Exception)
            {
                Console.WriteLine(@"Invalid parent category id number");
                return;
            }
            Category c = new Category(name, parentId);

            try
            {
                var cat = CategoryManager.AddCategory(c);
                Console.WriteLine(@"Successfully added new category " + cat.ToCliString());
            }
            catch (Exception)
            {
                Console.WriteLine(@"Error while adding a new category: Parent Id does not exist!");
            }
        }
Beispiel #4
0
        public ActionResult Save(Category category)
        {
            try
            {
                if (category.Name != null && category.Code != null)
                {
                    var IsAdd = _categoryManager.AddCategory(category);

                    if (IsAdd)
                    {
                        ViewBag.Smsg = " Save Successfully";
                    }
                    else
                    {
                        ViewBag.Fmsg = "Category Not Saved";
                    }
                }

                return(View(_categoryManager.GetAll()));
            }

            catch (Exception e)
            {
                ViewBag.Fmsg = e.Message;
            }

            return(View(_categoryManager.GetAll()));
        }
Beispiel #5
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (!IsValid())
            {
                return;
            }

            _category = new Category(codeTextBox.Text, nameTextBox.Text);

            if (_categoryManager.IsCodeExist(_category.Code))
            {
                MessageBox.Show($"Code : {_category.Code} Already Exist..!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (_categoryManager.IsNameExist(_category.Name))
            {
                MessageBox.Show($"Name : {_category.Name} Already Exist..!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (_categoryManager.AddCategory(_category))
            {
                showDataGridView.DataSource = _categoryManager.Display();
                MessageBox.Show("Added Successfully..!");
            }
            else
            {
                MessageBox.Show("Failed..!");
            }
        }
Beispiel #6
0
        public ActionResult AddCategory(Category category)
        {
            if (ModelState.IsValid)
            {
                //CacheHelper.RemoveCategoriesFromCache();
                CategoryManager categoryManager  = new CategoryManager();
                var             blResultCategory = categoryManager.AddCategory(category);
                if (blResultCategory.ErrorMessageObj.Count > 0)
                {
                    ErrorViewModel errorViewModel = new ErrorViewModel()
                    {
                        Items = blResultCategory.ErrorMessageObj,
                    };
                    return(View("Error", errorViewModel));
                }
                OkViewModel okViewModel = new OkViewModel()
                {
                    RedirectingUrl = "/Home/CategoryList",
                    Title          = "Kategori Eklendi"
                };

                return(View("Ok", okViewModel));
            }

            return(View(category));
        }
        public ActionResult AddCategory(Category category)
        {
            if (ModelState.IsValid)
            {
                if (_categoryManager.IsExistCategoryCode(category))
                {
                    ViewBag.codeExist = "Category Code Already Exists!";
                }
                else if (_categoryManager.IsExistCategory(category))
                {
                    ViewBag.nameExist = "Category Already Exists!";
                }
                else
                {
                    if (_categoryManager.AddCategory(category))
                    {
                        ViewBag.SuccessMsg = "Saved";
                    }
                    else
                    {
                        ViewBag.FailMsg = "Failed";
                    }
                }
            }
            else
            {
                ViewBag.FailMsg = "Validation Error";
            }

            return(View());
        }
Beispiel #8
0
        protected void addCategoryButton_Click(object sender, EventArgs e)
        {
            if (addCategoryNameTextBox.Text != "")
            {
                if (System.Text.RegularExpressions.Regex.IsMatch(addCategoryNameTextBox.Text, "^[a-zA-Z]"))
                {
                    CategoryModel aCategory = new CategoryModel();
                    DateTime      date      = DateTime.Now;
                    aCategory.CategoryName = addCategoryNameTextBox.Text;
                    aCategory.DateTime     = date.ToString("dd-MM-yy");

                    string message = addCategory.AddCategory(aCategory);
                    outputLabel.Text            = message;
                    outputLabel.ForeColor       = Color.Red;
                    addCategoryNameTextBox.Text = "";

                    allCategoryGridView.DataSource = addCategory.GetAllCategory();
                    allCategoryGridView.DataBind();
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Oops!", "VaidationMsg()", true);
                }
            }
            else
            {
                outputLabel.Text      = "Please Input a Category Name";
                outputLabel.ForeColor = Color.Red;
            }
        }
        private void btnAddCategory_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtCategoryName.Text != string.Empty)
                {
                    Category category = new Category()
                    {
                        CategoryName = txtCategoryName.Text,
                        Description  = txtCategoryDesc.Text
                    };

                    int categoryID = categoryManager.AddCategory(category);
                    logManager.InsertLog(new LOG.Entity.Log(DateTime.Now, $"Category Added : {categoryID}"));
                    //categoryManager.GetCategories();
                    MessageBox.Show("Category added");
                    ((Form1)Application.OpenForms["Form1"]).FillCategoryComboBox();
                    ((Form1)Application.OpenForms["Form1"]).FillCategoryList();
                    ((Form1)Application.OpenForms["Form1"]).FillCategoryComboBox();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Enter category name");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occured");
                logManager.InsertLog(new LOG.Entity.Log(DateTime.Now, ex.Message));
            }
        }
Beispiel #10
0
        public ActionResult CategoryAdd(string categoryName)
        {
            var manager = new CategoryManager(_categoryRepository, _unitOfWork);

            manager.AddCategory(categoryName);
            return(RedirectToAction("Categories"));
        }
Beispiel #11
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Category        catagory = new Category();
        CategoryManager manager  = new CategoryManager();

        catagory.Name = this.txtCatagory.Text.Trim();
        manager.AddCategory(catagory);
        this.gvCategory.DataSource = manager.GetCategories();
        this.gvCategory.DataBind();
    }
Beispiel #12
0
        public ActionResult Add(Category category)
        {
            if (ModelState.IsValid)
            {
                _categoryManager.AddCategory(category);
                category.Categories = _categoryManager.GetAll();
            }

            return(View(category));
        }
        public void CanAddCategory(string categoryName, bool success)
        {
            Categories category = new Categories()
            {
                // id does not need to be added
                CategoryName = categoryName
            };

            TResponse <Categories> response = manager.AddCategory(category);

            Assert.AreEqual(success, response.Success);
        }
Beispiel #14
0
 private void SaveButton_Click(object sender, EventArgs e)
 {
     messageLabel.Text      = "";
     messageLabel.ForeColor = Color.Red;
     if (String.IsNullOrEmpty(codeTextBox.Text))
     {
         messageLabel.Text = "Enter Code";
         return;
     }
     if (String.IsNullOrEmpty(nameTextBox.Text))
     {
         messageLabel.Text = "Enter Category Name";
         return;
     }
     category.Name = nameTextBox.Text;
     category.Code = codeTextBox.Text;
     if (SaveButton.Text.Equals("Save"))
     {
         if (_categoryManager.IsCodeDuplicate(category))
         {
             messageLabel.Text = "Category Code is Duplicate";
             codeTextBox.Text  = "";
             return;
         }
         if (_categoryManager.AddCategory(category))
         {
             messageLabel.ForeColor = Color.Green;
             messageLabel.Text      = "Saved Successfully";
         }
         else
         {
             messageLabel.Text = "Save failed";
         }
     }
     else
     {
         if (_categoryManager.UpdateCategory(category))
         {
             messageLabel.ForeColor = Color.Green;
             messageLabel.Text      = "Updated Successfully";
         }
         else
         {
             messageLabel.Text = "Update failed";
         }
         SaveButton.Text = "Save";
     }
     nameTextBox.Text = "";
     codeTextBox.Text = "";
     DisplayCategories();
 }
Beispiel #15
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            _category = new Category(codeTextBox.Text, nameTextBox.Text);

            if (_categoryManager.AddCategory(_category))
            {
                showDataGridView.DataSource = _categoryManager.Display();
                MessageBox.Show("Added Successfully..!");
            }
            else
            {
                MessageBox.Show("Failed..!");
            }
        }
        public ActionResult AddCategory(Categories category)
        {
            _categoryManager = CategoryManagerFactory.Create();
            var response = _categoryManager.AddCategory(category);

            if (response.Success == true)
            {
                return(RedirectToAction("Categories"));
            }
            else
            {
                return(RedirectToAction("Categories"));
            }
        }
Beispiel #17
0
        public JsonResult addOrEditCategory(Categories category)
        {
            ResponseModel result = new ResponseModel();

            if (category.ID > 0)
            {
                category.Uri = _postM.GenerateUriFormat(category.Uri);
                result       = _catM.UpdateCategory(category);
            }
            else
            {
                category.Uri        = _postM.GenerateUriFormat(category.Uri);
                category.CreateDate = DateTime.Now;
                result = _catM.AddCategory(category);
            }
            return(Json(result));
        }
Beispiel #18
0
    private void PutData()
    {
        Category cate = new Category();

        cate.Name = this.txt_BookCatagory.Text.Trim();
        CategoryManager.AddCategory(cate);
        XmlDocument xdTree = new XmlDocument();

        xdTree.Load(Server.MapPath("~/TreeView.xml"));
        XmlElement xmlNew = xdTree.CreateElement("siteMapNode");

        xmlNew.SetAttribute("title", cate.Name);
        xmlNew.SetAttribute("url", "BookList.aspx?typeid=1");//+cate.Id.ToString());
        xmlNew.SetAttribute("description", "");
        xdTree.SelectSingleNode("siteMapNode").AppendChild(xmlNew);
        xdTree.Save(Server.MapPath("~/TreeView.xml"));
    }
        public ActionResult AddCategory(Category c)
        {
            CategoryValidator cV      = new CategoryValidator();
            ValidationResult  results = cV.Validate(c);

            if (results.IsValid)
            {
                cm.AddCategory(c);
                return(RedirectToAction("Index"));
            }
            else
            {
                foreach (var item in results.Errors)
                {
                    ModelState.AddModelError(item.PropertyName, item.ErrorMessage);
                }
            }
            return(View());
        }
Beispiel #20
0
        public ActionResult AddCategory(Category p)
        {
            CategoryValidator validations = new CategoryValidator();
            ValidationResult  result      = validations.Validate(p);

            if (result.IsValid)
            {
                cm.AddCategory(p);
                return(RedirectToAction("Index"));
            }
            else
            {
                foreach (ValidationFailure item in result.Errors)
                {
                    ModelState.AddModelError(item.PropertyName, item.ErrorMessage);
                }
            }
            return(View());
        }
        public ActionResult Add(string categoryName)
        {
            CategoryManager manager = new CategoryManager();

            if (!string.IsNullOrEmpty(categoryName))
            {
                Category catagory = new Category();

                catagory.Name = categoryName;
                manager.AddCategory(catagory);
            }
            else
            {
                return(Content("<script>alert('请输入分类名称!');location.href='" + UrlHelper.GenerateContentUrl("~/Admin/Category/List", this.HttpContext) + "'</script>"));
            }

            List <Category> cates = manager.GetCategories();

            return(View("List", cates));
        }
Beispiel #22
0
        public ActionResult AddCategory(Category category)
        {
            CategoryValidator categoryValidator = new CategoryValidator();
            ValidationResult  validationResult  = categoryValidator.Validate(category);

            if (validationResult.IsValid)
            {
                categoryManager.AddCategory(category);
                return(RedirectToAction("GetAll"));
            }
            else
            {
                foreach (var item in validationResult.Errors)
                {
                    ModelState.AddModelError(item.PropertyName, item.ErrorMessage);
                }
            }

            return(View());
        }
Beispiel #23
0
        public ActionResult AddCategory(Category p)
        {
            //cm.AddCategory(p);
            CategoryValidator categoryValidator = new CategoryValidator();
            ValidationResult  result            = categoryValidator.Validate(p);

            if (result.IsValid)
            {
                cm.AddCategory(p);
                return(RedirectToAction("GetCategoryList"));
            }
            else
            {
                foreach (var item in result.Errors)
                {
                    ModelState.AddModelError(item.PropertyName, item.ErrorMessage);
                }
            }

            return(View());
        }
        public string AddCategory(string data)
        {
            if (!RightsManager.HasRight(SessionManager.CurrentUser.ID, Feature.AdminCategory))
            {
                return(bool.FalseString);
            }

            try
            {
                var u = JsonConvert.DeserializeObject <NameAsString>(data);
                if (CategoryManager.AddCategory(u.Name))
                {
                    return(bool.TrueString);
                }
            }
            catch
            {
            }

            return(bool.FalseString);
        }
Beispiel #25
0
        public ActionResult Add(CategoryViewModel categoryViewModel)
        {
            if (ModelState.IsValid)
            {
                // Code is already Exist
                var isCodeExist = _categoryManager.IsCodeExist(categoryViewModel.Code);
                if (isCodeExist)
                {
                    ModelState.AddModelError("CodeExist", "Code already exist");
                    return(this.View("Add"));
                }

                // Name is already Exist
                var isNameExist = _categoryManager.IsNameExist(categoryViewModel.Name);
                if (isNameExist)
                {
                    ModelState.AddModelError("NameExist", "Name already exist");
                    return(this.View("Add"));
                }

                Category category = new Category();
                category = Mapper.Map <Category>(categoryViewModel);

                if (_categoryManager.AddCategory(category))
                {
                    ViewBag.Message = "Saved";
                    return(RedirectToAction("Show", "Category"));
                }
                else
                {
                    ViewBag.Message = "Failed";
                }
            }
            else
            {
                ViewBag.Message = "Validation Error";
            }

            return(View());
        }
Beispiel #26
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (nameTextBox.Text.Length > 2)
            {
                try
                {
                    Category category = new Category();
                    category.Name = nameTextBox.Text;


                    bool result = categoryManager.AddCategory(category);

                    if (result == true)
                    {
                        warningLabel.Text = "Category Already Exist!";
                        return;
                    }
                    else
                    {
                        nameTextBox.Clear();
                        MessageBox.Show("Added Succesfully!");
                        warningLabel.Text = "";
                        //Update Function
                        CategoryForm_Load(this, null);
                        return;
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
            else
            {
                warningLabel.Text = "Name at least 3 character!";
                return;
            }
        }
Beispiel #27
0
        public ActionResult Add(CategoryViewModel categoryViewModel)
        {
            if (ModelState.IsValid)
            {
                Category category = new Category();
                category = Mapper.Map <Category>(categoryViewModel);

                if (_categoryManager.AddCategory(category))
                {
                    ViewBag.Message = "Saved";
                }
                else
                {
                    ViewBag.Message = "Failed";
                }
            }
            else
            {
                ViewBag.Message = "Validation Error";
            }

            return(View());
        }
Beispiel #28
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            category.Code = codeTextBox.Text;
            category.Name = nameTextBox.Text;

            if (saveButton.Text == "Update")
            {
                if (_categoryManager.IsUpdateCategory(category))
                {
                    MessageBox.Show("Category Updated Successfully");
                    //Edit();
                    List <Category> categories = _categoryManager.DisplayCategory();
                    showDataGridView.DataSource = categories;
                    saveButton.Text             = "Save";
                    SL();
                    Clear();
                    return;
                }
                else
                {
                    MessageBox.Show("Category Not Updated, Check details");
                    return;
                }
            }

            if (category.Code == "")
            {
                MessageBox.Show("Code Filed is Required");
                codeTextBox.Clear();
                return;
            }
            else if (!CheckIfNumeric(category.Code))
            {
                MessageBox.Show("Please enter numeric code.");
                codeTextBox.Clear();
                return;
            }
            else if (category.Code.Length != 4)
            {
                MessageBox.Show("Code filed is required 4 digit length");
                codeTextBox.Clear();
                return;
            }
            else if (_categoryManager.IsExistCode(category))
            {
                MessageBox.Show("Code is already exist");
                codeTextBox.Clear();
                return;
            }

            if (category.Name == "")
            {
                MessageBox.Show("Name Filed is Required");
                return;
            }
            else if (CheckIfNumeric(category.Name))
            {
                MessageBox.Show("Required Name in this field.");
                nameTextBox.Clear();
                return;
            }
            else if (_categoryManager.IsExistName(category))
            {
                MessageBox.Show("Name is already exist");
                nameTextBox.Clear();
                return;
            }

            if (_categoryManager.AddCategory(category))
            {
                MessageBox.Show("Category Added Successfully");
                //Edit();
                List <Category> categories = _categoryManager.DisplayCategory();
                showDataGridView.DataSource = categories;
                //saveButton.Text = "Update";
                SL();
                Clear();
            }
            else
            {
                MessageBox.Show("Category Not Added");
            }
        }
Beispiel #29
0
 public ActionResult AddCategory(Category category)
 {
     categoryManager.AddCategory(category);
     return(RedirectToAction("CategoryList"));
 }
Beispiel #30
0
        private void addButton_Click(object sender, EventArgs e)
        {
            _category.ID = selectedID;

            if (String.IsNullOrEmpty(categoryCodeTextBox.Text))
            {
                MessageBox.Show("Please Enter Code");
                return;
            }


            if (categoryCodeTextBox.TextLength != 4)
            {
                MessageBox.Show("Code Must be 4 Charecter");
            }


            if (!_categoryManager.IsCodeUniqe(categoryCodeTextBox.Text, selectedID))
            {
                MessageBox.Show("Code Must be unique");
                return;
            }


            if (String.IsNullOrEmpty(categoryNameTextBox.Text))
            {
                MessageBox.Show("Please Enter a Name");
                return;
            }
            if (!_categoryManager.IsNameUniqe(categoryNameTextBox.Text, selectedID))
            {
                MessageBox.Show("Name Must be unique");
                return;
            }
            _category.Code = categoryCodeTextBox.Text;
            _category.Name = categoryNameTextBox.Text;

            if (addButton.Text == "Save")
            {
                if (_categoryManager.AddCategory(_category))
                {
                    MessageBox.Show("Data Saved Successfully..!!");
                    showDataGridView.DataSource = _categoryManager.Display();
                }
                else
                {
                    MessageBox.Show("Not Saved..!!");
                }
            }

            else
            {
                if (_categoryManager.UpdateCategory(_category))
                {
                    addButton.Text = "Save";

                    MessageBox.Show("Updated Successfully..!!");
                    showDataGridView.DataSource = _categoryManager.Display();
                }
                else
                {
                    MessageBox.Show("Not Updated..!!");
                }
            }
            categoryCodeTextBox.Clear();
            categoryNameTextBox.Clear();
        }