Exemplo n.º 1
0
    public static TEntityAction Create (TCategory category, TOperation operation)
    {
      var model = Create (category);
      model.Operation.Select (category, operation);

      return (model);
    }
Exemplo n.º 2
0
    public void Select (TCategory category, TOperation operation, TExtension extension)
    {
      CategoryType.Select (category);

      Operation = operation;
      Extension = extension;
    }
Exemplo n.º 3
0
 public static void Collection (TCategory category, Collection<TActionComponent> gadgets, TEntityAction entityAction)
 {
   if (gadgets.NotNull () && entityAction.NotNull ()) {
     switch (category) {
       case TCategory.Material:
         TGadgetMaterialConverter.Collection (gadgets, entityAction);
         break;
      
       case TCategory.Target:
         TGadgetTargetConverter.Collection (gadgets, entityAction);
         break;
       
       case TCategory.Test:
         TGadgetTestConverter.Collection (gadgets, entityAction);
         break;
       
       case TCategory.Registration:
         TGadgetRegistrationConverter.Collection (gadgets, entityAction);
         break;
       
       case TCategory.Result:
         TGadgetResultConverter.Collection (gadgets, entityAction);
         break;
       
       case TCategory.Report:
         TGadgetReportConverter.Collection (gadgets, entityAction);
         break;
     }
   }
 }
Exemplo n.º 4
0
        public async Task <IActionResult> NewCategory([Bind("CatId,CatType,CatBed,CatDescription,CatPrice")] TCategory tCat)
        {
            if (HttpContext.Session.GetString("UType") != "A")
            {
                TempData["Error"] = "Insufficient login permission";
                return(RedirectToAction("Index", "Login"));
            }
            SetDashboard(2);
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Add(tCat);
                    await _context.SaveChangesAsync();

                    TempData["Message"] = "Category registered.";
                    return(RedirectToAction(nameof(ViewCategory)));
                }
                catch (Exception)
                {
                    TempData["Error"] = "Unable to register this category. Please try agian";
                    return(View(tCat));
                }
            }

            TempData["Error"] = "Unable to register this category. Please try agian";
            return(View(tCat));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> EditCategory(string id, [Bind("CatId,CatType,CatBed,CatDescription,CatPrice")] TCategory tCategory)
        {
            SetDashboard(2);
            if (id != tCategory.CatId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_context.TCategories.Any(e => e.CatId == id))
                    {
                        TempData["Error"] = "Couldn't find the category ID. Please try again";
                        return(RedirectToAction(nameof(ViewCategory)));
                    }
                    else
                    {
                        TempData["Error"] = "Couldn't update the category. Please try again";
                        return(RedirectToAction(nameof(ViewCategory)));
                    }
                }
                TempData["Message"] = "Update successfull.";
                return(RedirectToAction(nameof(ViewCategory)));
            }

            TempData["Error"] = "Couldn't update the category. Please try again";
            return(View(tCategory));
        }
Exemplo n.º 6
0
    public static void Select (TCategory category, TActionComponent component, TEntityAction entityAction)
    {
      if (component.NotNull () && entityAction.NotNull ()) {
        switch (category) {
          case TCategory.Material:
            TGadgetMaterialConverter.Select (component, entityAction);
            break;

          case TCategory.Target:
            TGadgetTargetConverter.Select (component, entityAction);
            break;

          case TCategory.Test:
            TGadgetTestConverter.Select (component, entityAction);
            break;

          case TCategory.Registration:
            TGadgetRegistrationConverter.Select (component, entityAction);
            break;

          case TCategory.Result:
            TGadgetResultConverter.Select (component, entityAction);
            break;

          case TCategory.Report:
            TGadgetReportConverter.Select (component, entityAction);
            break;
        }
      }
    }
Exemplo n.º 7
0
    public static TEntityAction Create (TCategory category, TOperation operation, Infrastructure.TExtension extension)
    {
      var model = Create (category);
      model.Operation.Select (category, operation, extension);

      return (model);
    }
Exemplo n.º 8
0
        public virtual ActionResult Editar(int id)
        {
            var category = TCategory.Load(id);

            ViewBag.EnumProfileClient = EnumHelper.ListAll <ProfileClient>().ToSelectList(x => x, x => x.Description());
            return(View(category));
        }
Exemplo n.º 9
0
        public virtual ActionResult Cadastrar()
        {
            var filme = new TMovie();

            ViewBag.EnumFormatMovie = EnumHelper.ListAll <FormatMovie>().ToSelectList(x => x, x => x.Description());
            ViewBag.EnumTypeMovie   = EnumHelper.ListAll <TypeMovie>().ToSelectList(x => x, x => x.Description());
            ViewBag.Category        = TCategory.ListAll().ToSelectList(x => x.Id, x => x.Name);
            return(View(filme));
        }
Exemplo n.º 10
0
        public virtual ActionResult Cadastrar()
        {
            var cliente = new TClient();

            ViewBag.MostraSenha       = true;
            ViewBag.EnumProfileClient = EnumHelper.ListAll <ProfileClient>().ToSelectList(x => x, x => x.Description());
            ViewBag.Category          = TCategory.ListAll().ToSelectList(x => x.Id, x => x.Name);
            return(View(cliente));
        }
 public ShopModel.Category TransporterToModel(TCategory t)
 {
     ShopModel.Category category = new ShopModel.Category
     {
         Category_Id = t.id,
         Name        = t.name,
         Timestamp   = t.timestamp
     };
     return(category);
 }
Exemplo n.º 12
0
        public virtual ActionResult Editar(int id)
        {
            var filme           = TMovie.Load(id);
            var categoriasFilme = filme.TMovieCategories.Select(x => x.Category.Id).ToList();

            ViewBag.EnumFormatMovie = EnumHelper.ListAll <FormatMovie>().ToSelectList(x => x, x => x.Description());
            ViewBag.EnumTypeMovie   = EnumHelper.ListAll <TypeMovie>().ToSelectList(x => x, x => x.Description());
            ViewBag.Category        = TCategory.List(x => !categoriasFilme.Contains(x.Id)).ToSelectList(x => x.Id, x => x.Name);
            return(View(filme));
        }
Exemplo n.º 13
0
        public void CreateCategory(TCategory category)
        {
            if (category == null)
            {
                throw new ArgumentNullException(nameof(category));
            }

            _context.TCategories.Add(category);
            _context.SaveChanges();
        }
Exemplo n.º 14
0
 public static void ModifyStatus (TCategory category, TActionComponent component, TEntityAction entityAction)
 {
   if (component.NotNull () && entityAction.NotNull ()) {
     switch (category) {
       case TCategory.Result:
         TGadgetResultConverter.ModifyStatus (component, entityAction);
         break;
     }
   }
 }
        public void UpdateCategory(int categoryId, string cateName)
        {
            using (DataLinqToSQLDataContext category = new DataLinqToSQLDataContext())
            {
                TCategory editCategory = category.TCategories.SingleOrDefault(x => x.CategoryID == categoryId);

                editCategory.Name = cateName;

                category.SubmitChanges();
            }
        }
        public TCategory ModelToTransporter(ShopModel.Category t)
        {
            TCategory category = new TCategory
            {
                id        = t.Category_Id,
                name      = t.Name,
                timestamp = t.Timestamp
            };

            return(category);
        }
Exemplo n.º 17
0
 public void SaveCategories(TMovie model)
 {
     TMovieCategory.Delete(x => x.Movie.Id == model.Id);
     for (int i = 0; i < model.Categories.Length; i++)
     {
         new TMovieCategory()
         {
             Movie    = model,
             Category = TCategory.Load(model.Categories[i])
         }.Save();
     }
 }
Exemplo n.º 18
0
 public virtual ActionResult Editar(TCategory model)
 {
     try
     {
         model.Update();
         TempData["Alerta"] = new Alert("success", "Seu gênero foi editado com sucesso");
         return(RedirectToAction("Index"));
     }
     catch (SimpleValidationException ex)
     {
         return(HandleViewException(model, ex));
     }
 }
        public void InsertCategory(string categoryName)
        {
            using (DataLinqToSQLDataContext category = new DataLinqToSQLDataContext())
            {
                TCategory newCategory = new TCategory
                {
                    Name = categoryName
                };

                category.TCategories.InsertOnSubmit(newCategory);
                category.SubmitChanges();
            }
        }
Exemplo n.º 20
0
    public static void SelectMany (TCategory category, Collection<TActionComponent> gadgets, TEntityAction entityAction)
    {
      if (gadgets.NotNull () && entityAction.NotNull ()) {
        switch (category) {
          case TCategory.Test:
            TGadgetTestConverter.SelectMany (gadgets, entityAction);
            break;

          case TCategory.Result:
            TGadgetResultConverter.SelectMany (gadgets, entityAction);
            break;
        }
      }
    }
Exemplo n.º 21
0
 public void SavePreferences(TClient model)
 {
     TPreference.Delete(x => x.Client.Id == model.Id);
     if (model.Preference != null)
     {
         for (int i = 0; i < model.Preference.Length; i++)
         {
             new TPreference()
             {
                 Client   = model,
                 Category = TCategory.Load(model.Preference[i])
             }.Save();
         }
     }
 }
Exemplo n.º 22
0
        private void renameButton_Click(object sender, EventArgs e)
        {
            TCategory t = (TCategory)categoriesBox.SelectedItem;

            t.name = newNameBox.Text;
            if (categoryRef.Update(t))
            {
                createLabel.Text = "Succesfully renamed";
            }
            else
            {
                createLabel.Text = "Error renaming category";
            }
            newNameBox.Clear();
            refreshButton.PerformClick();
        }
Exemplo n.º 23
0
        public virtual ActionResult Editar(int id)
        {
            var cliente      = TClient.Load(id);
            var preferencias = cliente.TPreferences.Select(x => x.Category.Id).ToList();

            ViewBag.MostraSenha       = false;
            ViewBag.EnumProfileClient = EnumHelper.ListAll <ProfileClient>().ToSelectList(x => x, x => x.Description());
            if (preferencias.Count != 0)
            {
                ViewBag.Category = TCategory.List(x => !preferencias.Contains(x.Id)).ToSelectList(x => x.Id, x => x.Name);
            }
            else
            {
                ViewBag.Category = TCategory.ListAll().ToSelectList(x => x.Id, x => x.Name);
            }
            return(View(cliente));
        }
Exemplo n.º 24
0
        private void createCategory_Click(object sender, EventArgs e)
        {
            TCategory t = new TCategory();

            if (newCategory.ToString() != "")
            {
                t.name = newCategory.Text;
                if (categoryRef.Create(t))
                {
                    createLabel.Text = "Category successfuly created";
                }
                else
                {
                    createLabel.Text = "Error creating category";
                }
            }
            newCategory.Clear();
            refreshButton.PerformClick();
        }
Exemplo n.º 25
0
        public void FindById_FromRoot()
        {
            // 1、分类的多态
            //---------------------------------------

            Console.WriteLine("---------- 分类多态 -----------");

            // 也可以直接创建父类
            TCategory category = new TCategory();

            category.Name = "父类的分类之FindById_FromRoot";
            db.insert(category);

            Assert.Greater(category.Id, 0);

            // 多态查询:正确判断具体的结果是父类
            TCategory cat = TCategory.findById(category.Id);

            Assert.AreEqual(category.Name, cat.Name);
            Assert.AreEqual(typeof(TCategory), cat.GetType());

            Console.WriteLine("---------- 多态关联 -----------");


            // 2、 数据上面 关联到 多态的分类
            //---------------------------------------
            TDataRoot root = new TDataRoot();

            root.Title    = "我是父类之一";
            root.Body     = "父类的内容之一";
            root.Category = category;
            db.insert(root);

            Assert.Greater(root.Id, 0);
            TDataRoot data = TDataRoot.findById(root.Id);

            Assert.IsNotNull(data);
            Assert.AreEqual(root.Title, data.Title);
            Assert.AreEqual(category.Id, data.Category.Id);
            Assert.AreEqual(category.Name, data.Category.Name);
        }
Exemplo n.º 26
0
        public ActionResult Create(TCategory category)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    objAdminBL.categoryBL.Insert(category);
                    TempData["Msg"] = "New category added successfully!";
                    return(RedirectToAction("Index"));
                }

                else
                {
                    return(View("Index"));
                }
            }
            catch (Exception e)
            {
                TempData["Msg"] = "Error!" + e.Message;
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 27
0
        public bool CategorySave(TCategory Category)
        {
            if (Category.ParentId == default)
            {
                Category.ParentId = null;
            }

            var userId = Guid.Parse(HttpContext.Session.GetString("userId"));



            if (Category.Id == default)
            {
                //执行添加

                Category.Id = Guid.NewGuid();

                Category.CreateTime   = DateTime.Now;
                Category.CreateUserId = userId;
                Category.IsDelete     = false;

                db.TCategory.Add(Category);
            }
            else
            {
                //执行修改
                var dbCategory = db.TCategory.Where(t => t.Id == Category.Id).FirstOrDefault();

                dbCategory.ParentId = Category.ParentId;
                dbCategory.Name     = Category.Name;
                dbCategory.Remarks  = Category.Remarks;
                dbCategory.Sort     = Category.Sort;
            }

            db.SaveChanges();

            return(true);
        }
Exemplo n.º 28
0
        public IActionResult CategoryEdit(Guid channelid, Guid id)
        {
            IDictionary <string, object> list = new Dictionary <string, object>();

            var categoryList = db.TCategory.Where(t => t.IsDelete == false && t.ChannelId == channelid).OrderBy(t => t.Sort).ToList();

            list.Add("categoryList", categoryList);


            if (id == default)
            {
                var category = new TCategory();
                category.ChannelId = channelid;
                list.Add("categoryInfo", category);
            }
            else
            {
                var Category = db.TCategory.Where(t => t.Id == id).FirstOrDefault();
                list.Add("categoryInfo", Category);
            }

            return(View(list));
        }
Exemplo n.º 29
0
        public virtual ActionResult ListarGenero(int id)
        {
            var genero = TCategory.Load(id);

            return(PartialView("_listar-genero", genero));
        }
Exemplo n.º 30
0
        public void A_Insert()
        {
            wojiluOrmTestInit.ClearLog();
            wojiluOrmTestInit.InitMetaData();

            ConsoleTitleUtil.ShowTestTitle( "Insert" );

            //wojilu.file.Delete( "log.txt" );

            // �˴�Ӧ����������������
            // Ȼ��������������ݣ�ͬʱ����insert sql������Id��ֵ��

            // �ܹ����46������
            for (int i = 0; i < 20; i++) {

                // �ڲ������ݵ�ʱ�򣬶�̬����û���ر���Ҫע���

                TPostCategory pcat = new TPostCategory();
                pcat.Name = "post���ӷ���";
                pcat.Hits = new Random().Next( 1, 100 );
                db.insert( pcat );
                Assert.Greater( pcat.Id, 0 );

                TTopicCategory tcat = new TTopicCategory();
                tcat.Name = "topic�������";
                tcat.ReplyCount = new Random().Next( 1, 200 );
                db.insert( tcat );
                Assert.Greater( tcat.Id, 0 );

                TPost post = new TPost();
                post.Title = "post_34��������Ա�����º�";
                post.Body = "ϣ����Ĺ�ȥ�ķ����ִ�Y��¯�ĒY���_��";
                post.Uid = "����";
                post.Category = pcat; // ��̬�������
                post.Hits = new Random().Next();
                db.insert( post );
                Assert.Greater( post.Id, 0 );

                TTopic topic = new TTopic();
                topic.Title = "topic_������������";
                topic.Body = "�����ƺ�����֣��������Ȼ�Dz���˵�ġ����Ǻ�������˵�����ܡ������һ�����䡣";
                topic.Uid = "����";
                topic.Category = tcat;
                topic.Hits = new Random().Next( 34, 10039343 );
                topic.ReplyCount = 3;
                db.insert( topic );
                Assert.Greater( topic.Id, 0 );

            }

            for (int i = 0; i < 3; i++) {

                // ����������ӣ�����������ƺ����ӷ���������ͬ������������Ե�ʱ���Ƿ�Ҳ�ڶ�̬��ѯ�����
                TTopicCategory tcatfake = new TTopicCategory();
                tcatfake.Name = "zzTopic���ӷ���";
                tcatfake.ReplyCount = new Random().Next( 1, 200 );
                db.insert( tcatfake );
                Assert.Greater( tcatfake.Id, 0 );

                TTopic topicfake = new TTopic();
                topicfake.Title = "zzTopic������������";
                topicfake.Body = "�����ƺ�����֣��������Ȼ�Dz���˵�ġ����Ǻ�������˵�����ܡ������һ�����䡣";
                topicfake.Uid = "����";
                topicfake.Category = tcatfake;
                topicfake.Hits = new Random().Next( 34, 10039343 );
                topicfake.ReplyCount = 3;
                db.insert( topicfake );
                Assert.Greater( topicfake.Id, 0 );

                // ֱ����Ӹ���ľ�������
                TCategory category = new TCategory();
                category.Name = "post���ӷ���";
                db.insert( category );

                TDataRoot root = new TDataRoot();
                root.Title = "zzParent���Ǹ���֮init��ʼ��";
                root.Body = "���������֮init��ʼ��";
                root.Category = category;
                db.insert( root );
            }

            insertAbstractTest();
        }
Exemplo n.º 31
0
        public void FindById_FromRoot()
        {
            // 1������Ķ�̬
            //---------------------------------------

            Console.WriteLine( "---------- �����̬ -----------" );

            // Ҳ����ֱ�Ӵ�������
            TCategory category = new TCategory();
            category.Name = "����ķ���֮FindById_FromRoot";
            db.insert( category );

            Assert.Greater( category.Id, 0 );

            // ��̬��ѯ����ȷ�жϾ���Ľ���Ǹ���
            TCategory cat = TCategory.findById( category.Id );
            Assert.AreEqual( category.Name, cat.Name );
            Assert.AreEqual( typeof( TCategory ), cat.GetType() );

            Console.WriteLine( "---------- ��̬���� -----------" );

            // 2�� �������� ������ ��̬�ķ���
            //---------------------------------------
            TDataRoot root = new TDataRoot();
            root.Title = "���Ǹ���֮һ";
            root.Body = "���������֮һ";
            root.Category = category;
            db.insert( root );

            Assert.Greater( root.Id, 0 );
            TDataRoot data = TDataRoot.findById( root.Id );
            Assert.IsNotNull( data );
            Assert.AreEqual( root.Title, data.Title );
            Assert.AreEqual( category.Id, data.Category.Id );
            Assert.AreEqual( category.Name, data.Category.Name );
        }
Exemplo n.º 32
0
 public ActionResult <TCategory> Post(TCategory category)
 {
     _category.CreateCategory(category);
     return(Ok());
 }
Exemplo n.º 33
0
        public void FindById_FromRoot()
        {
            // 1、分类的多态
            //---------------------------------------

            Console.WriteLine( "---------- 分类多态 -----------" );

            // 也可以直接创建父类
            TCategory category = new TCategory();
            category.Name = "父类的分类之FindById_FromRoot";
            db.insert( category );

            Assert.Greater( category.Id, 0 );

            // 多态查询:正确判断具体的结果是父类
            TCategory cat = TCategory.findById( category.Id );
            Assert.AreEqual( category.Name, cat.Name );
            Assert.AreEqual( typeof( TCategory ), cat.GetType() );

            Console.WriteLine( "---------- 多态关联 -----------" );

            // 2、 数据上面 关联到 多态的分类
            //---------------------------------------
            TDataRoot root = new TDataRoot();
            root.Title = "我是父类之一";
            root.Body = "父类的内容之一";
            root.Category = category;
            db.insert( root );

            Assert.Greater( root.Id, 0 );
            TDataRoot data = TDataRoot.findById( root.Id );
            Assert.IsNotNull( data );
            Assert.AreEqual( root.Title, data.Title );
            Assert.AreEqual( category.Id, data.Category.Id );
            Assert.AreEqual( category.Name, data.Category.Name );
        }
Exemplo n.º 34
0
        public void A_Insert()
        {
            wojiluOrmTestInit.ClearLog();
            wojiluOrmTestInit.InitMetaData();

            ConsoleTitleUtil.ShowTestTitle( "Insert" );

            //wojilu.file.Delete( "log.txt" );

            // 此处应该先向基类添加数据
            // 然后向子类添加数据(同时调整insert sql,插入Id的值)

            // 总共添加46条数据
            for (int i = 0; i < 20; i++) {

                // 在插入数据的时候,多态关联没有特别需要注意的

                TPostCategory pcat = new TPostCategory();
                pcat.Name = "post帖子分类";
                pcat.Hits = new Random().Next( 1, 100 );
                db.insert( pcat );
                Assert.Greater( pcat.Id, 0 );

                TTopicCategory tcat = new TTopicCategory();
                tcat.Name = "topic主题分类";
                tcat.ReplyCount = new Random().Next( 1, 200 );
                db.insert( tcat );
                Assert.Greater( tcat.Id, 0 );

                TPost post = new TPost();
                post.Title = "post_34名美国议员联名致函";
                post.Body = "希腊深化的过去的发恩持大扽肯炉衬扽拉歘称";
                post.Uid = "张三";
                post.Category = pcat; // 多态关联添加
                post.Hits = new Random().Next();
                db.insert( post );
                Assert.Greater( post.Id, 0 );

                TTopic topic = new TTopic();
                topic.Title = "topic_我是主题帖子";
                topic.Body = "标题似乎很奇怪,秘密嘛,自然是不能说的。于是乎“不能说的秘密”便成了一个病句。";
                topic.Uid = "李四";
                topic.Category = tcat;
                topic.Hits = new Random().Next( 34, 10039343 );
                topic.ReplyCount = 3;
                db.insert( topic );
                Assert.Greater( topic.Id, 0 );

            }

            for (int i = 0; i < 3; i++) {

                // 添加主题帖子,让其分类名称和帖子分类名称相同,便于下面测试的时候看是否也在多态查询结果中
                TTopicCategory tcatfake = new TTopicCategory();
                tcatfake.Name = "zzTopic帖子分类";
                tcatfake.ReplyCount = new Random().Next( 1, 200 );
                db.insert( tcatfake );
                Assert.Greater( tcatfake.Id, 0 );

                TTopic topicfake = new TTopic();
                topicfake.Title = "zzTopic我是主题帖子";
                topicfake.Body = "标题似乎很奇怪,秘密嘛,自然是不能说的。于是乎“不能说的秘密”便成了一个病句。";
                topicfake.Uid = "李四";
                topicfake.Category = tcatfake;
                topicfake.Hits = new Random().Next( 34, 10039343 );
                topicfake.ReplyCount = 3;
                db.insert( topicfake );
                Assert.Greater( topicfake.Id, 0 );

                // 直接添加父类的具体数据
                TCategory category = new TCategory();
                category.Name = "post帖子分类";
                db.insert( category );

                TDataRoot root = new TDataRoot();
                root.Title = "zzParent我是父类之init初始化";
                root.Body = "父类的内容之init初始化";
                root.Category = category;
                db.insert( root );
            }

            insertAbstractTest();
        }