Exemplo n.º 1
0
        public ActionResult Update(Guid id)
        {
            SubCategory subcategory = ss.GetByID(id);

            ViewBag.CategoryID = new SelectList(cs.GetActive(), "ID", "CategoryName", subcategory.CategoryID);
            return(View(ss.GetByID(id)));
        }
        public String Delete(int level, int ID)
        {
            try
            {
                if (level == 1)
                {
                    if (mainCategoryService.GetByID(ID) != null)
                    {
                        mainCategoryService.Remove(ID);
                        return("mainCategory Deleted Sucessfully");
                    }
                    else
                    {
                        return("mainCategory Not Found !");
                    }
                }
                else if (level == 2)
                {
                    if (subCategoryService.GetByID(ID) != null)
                    {
                        subCategoryService.Remove(ID);
                        return("subCategory Deleted Sucessfully");
                    }
                    else
                    {
                        return("subCategory Not Found !");
                    }
                }
                else if (level == 3)
                {
                    if (trackService.GetByID(ID) != null)
                    {
                        trackService.Remove(ID);
                        return("track Deleted Sucessfully");
                    }
                    else
                    {
                        return("track Not Found !");
                    }
                }
                else if (level == 4)
                {
                    if (courseService.GetByID(ID) != null)
                    {
                        courseService.Remove(ID);
                        return("course Deleted Sucessfully");
                    }
                    else
                    {
                        return("course Not Found !");
                    }
                }
            }
            catch (Exception ex)
            {
                return("Something Went Wrong !!");
            }

            return("");
        }
        //HttpGet sayfayı gösterecek
        public ActionResult Update(Guid id)
        {
            //Sayfaya 2 model gidecek . biri Kategori Listesi , biri güncellenecek verinin kendisidir.
            //Bu yüzden Admin Areasında viewModel class'ı açtık
            SubCategoryVM vm = new SubCategoryVM();

            vm.KatListesi = _categoryService.GetActive();

            //sayfayada güncellenecek veriyi önce veritabanından buluyoruz.
            SubCategory orjVeri = _subcategoryService.GetByID(id);

            vm.ID          = orjVeri.ID;
            vm.Name        = orjVeri.Name;
            vm.Description = orjVeri.Description;
            vm.CategoryID  = orjVeri.CategoryID;

            return(View(vm));
        }
        public ResultViewModel <SubCategoryViewModel> GetByID(int id)
        {
            ResultViewModel <SubCategoryViewModel> result
                = new ResultViewModel <SubCategoryViewModel>();

            try
            {
                var subCategory = subCategoryService.GetByID(id);
                result.Successed = true;
                result.Data      = subCategory;
            }
            catch (Exception ex)
            {
                result.Successed = false;
                result.Message   = "Something Went Wrong !!";
            }
            return(result);
        }
Exemplo n.º 5
0
        public ResultViewModel <DataDetails> GetByID(int ID, int Level, int PageSize, int PageIndex)
        {
            ResultViewModel <DataDetails> result
                = new ResultViewModel <DataDetails>();
            DataDetails details = new DataDetails();
            int         count   = 0;

            try
            {
                switch (Level)
                {
                case 1:
                    details.LevelDetails = mainCategoryService.GetByID(ID);
                    details.Childs       = subCategoryService.GetByParentID(out count, ID, PageIndex, PageSize).Select(i => i.ToHomeViewmodel()).ToList();
                    break;

                case 2:
                    details.LevelDetails = subCategoryService.GetByID(ID);
                    details.Childs       = trackService.GetByParentID(out count, ID, PageIndex, PageSize).Select(i => i.ToHomeViewmodel()).ToList();
                    break;

                case 3:
                    details.LevelDetails = trackService.GetByID(ID).ToViewModel();
                    details.Childs       = courseService.GetByParentID(out count, ID, PageIndex, PageSize).Select(i => i.ToHomeViewmodel()).ToList();
                    //details.Childs = trackService.GetByID(ID).Courses.Select(i => i.Course.ToViewModel().ToHomeViewmodel()).ToList();
                    break;
                }
                result.Data      = details;
                result.Successed = true;
                result.Count     = count;
            }
            catch (Exception ex)
            {
                result.Successed = false;
                result.Message   = "Something Went Wrong !!";
            }
            return(result);
        }