Example #1
0
        public static void CreateAndEditCategory(string value, string name, string Code, string Description, int?OrderNo)
        {
            Erp.Domain.Repositories.CategoryRepository _categoryRepository = new Erp.Domain.Repositories.CategoryRepository(new Domain.ErpDbContext());
            var ktra = _categoryRepository.GetCategoryByCode(Code).Where(x => x.OrderNo == OrderNo);

            if (ktra.Count() > 0)
            {
                var q = ktra.FirstOrDefault();
                if (q != null)
                {
                    q.ModifiedUserId = WebSecurity.CurrentUserId;
                    q.ModifiedDate   = DateTime.Now;
                    q.Value          = value;
                    q.Code           = Code;
                    q.Name           = name;
                    q.Description    = Description;
                    _categoryRepository.UpdateCategory(q);
                }
            }
            else
            {
                var category = new Category();
                category.CreatedUserId  = WebSecurity.CurrentUserId;
                category.ModifiedUserId = WebSecurity.CurrentUserId;
                category.CreatedDate    = DateTime.Now;
                category.ModifiedDate   = DateTime.Now;
                category.Value          = value;
                category.Code           = Code;
                category.Name           = name;
                category.Description    = Description;
                category.OrderNo        = OrderNo;
                _categoryRepository.InsertCategory(category);
            }
        }
Example #2
0
        public static void DeleteCategory(string value, string Code)
        {
            Erp.Domain.Repositories.CategoryRepository _categoryRepository = new Erp.Domain.Repositories.CategoryRepository(new Domain.ErpDbContext());
            var ktra = _categoryRepository.GetCategoryByCode(Code).Where(x => x.Value == value);

            if (ktra.Count() > 0)
            {
                var q = ktra.FirstOrDefault();
                if (q != null)
                {
                    _categoryRepository.DeleteCategory(q.Id);
                }
            }
        }