コード例 #1
0
        public ActionResult AddDeclaration(DeclarationModel declaration)
        {
            ViewBag.Directory = DirectoryTypes.Home;
            InitDropDownItems(CategoryRepository.GetCategoryIdBySubCategoryId(declaration.SubCategoryId), RegionRepository.GetRegionIdByCityyId(declaration.CityId));
            if (ModelState.IsValid)
            {
                var newDeclaration = new Declaration
                {
                    Name          = declaration.NameD,
                    Description   = declaration.Description,
                    SubCategoryId = declaration.SubCategoryId,
                    Type          = DeclarationTypes.OnModeration,
                    UserId        = UserId,
                    CityId        = declaration.CityId,
                };

                DeclarationRepository.Add(newDeclaration);

                foreach (var img in declaration.Images)
                {
                    if (!string.IsNullOrEmpty(img))
                    {
                        ImageRepository.Add(new Image
                        {
                            Name          = img,
                            DeclarationId = newDeclaration.Id,
                        });
                    }
                }
                return(RedirectToAction("Index", "Home"));
            }

            return(View(declaration));
        }
コード例 #2
0
        public JsonResult SearchValue(string searchWord, int curentItemsCount = 0, SortTypes sortType = SortTypes.ByDate)
        {
            var searchSize         = 10;
            var searchDeclarations = DeclarationRepository.SearchDeclarations(searchWord);

            if (sortType == SortTypes.ByDate)
            {
                searchDeclarations = searchDeclarations.OrderByDescending(x => x.CreatedDate).ToList();
            }
            else if (sortType == SortTypes.PriceAsc)
            {
                searchDeclarations = searchDeclarations.OrderBy(x => x.Price).ToList();
            }

            var totalItemsCount = searchDeclarations.Count();

            var items = searchDeclarations
                        .Skip(curentItemsCount)
                        .Take(searchSize)
                        .ToList();

            curentItemsCount += items.Count;

            var html = this.RenderRazorViewToString("SearchValue", items);

            return(Json(new { Data = html, CurentItemsCount = curentItemsCount, TotalItemsCount = totalItemsCount, SortType = sortType.ToString() }));
        }
コード例 #3
0
        //[HttpGet]
        //public ActionResult Declarations(int? idCategory, int? idSubCategory)
        //{
        //    return RedirectToAction("Index", new {idCategory, idSubCategory});
        //}

        public ActionResult Declaration(int?declarationId)
        {
            var declaration = DeclarationRepository.GetById(declarationId);

            ViewBag.Directory = DirectoryTypes.Declaration;
            return(View(declaration));
        }
コード例 #4
0
 public void GetStudentDeclarationJiaoWu_UsingOfType()
 {
     var repo = new DeclarationRepository(_context);
     var query = repo.Find(t =>
         t.SchoolYearTerm.Year == "2013-2014" &&
         t.SchoolYearTerm.Term == "2"
         ).OfType<StudentDeclaration>();
     Assert.IsTrue(query.Count() > 99);
 }
コード例 #5
0
        public void GetStudentDeclarationJiaoWu_UsingOfType()
        {
            var repo  = new DeclarationRepository(_context);
            var query = repo.Find(t =>
                                  t.SchoolYearTerm.Year == "2013-2014" &&
                                  t.SchoolYearTerm.Term == "2"
                                  ).OfType <StudentDeclaration>();

            Assert.IsTrue(query.Count() > 99);
        }
コード例 #6
0
        public BaseController()
        {
            UserRepository        = new UserRepository();
            DeclarationRepository = new DeclarationRepository();
            CategoryRepository    = new CategoryRepository();
            RegionRepository      = new RegionRepository();
            ImageRepository       = new ImageRepository();
            if (UserEmail != String.Empty)
            {
                UserName = UserRepository.GetByEmail(UserEmail).Name;
            }

            ViewBags();
        }
コード例 #7
0
        public ActionResult DeclarationList(int page = 1)
        {
            var declarations = DeclarationRepository.GetDeclarationsByDeclarationType(DeclarationTypes.OnModeration).ToList();
            int pageSize     = 5; // количество элементов на странице

            var count = declarations.Count();

            var items = declarations
                        .OrderBy(x => x.CreatedDate)
                        .Skip((page - 1) * pageSize)
                        .Take(pageSize)
                        .ToList();

            ViewBag.PageSize     = pageSize;
            ViewBag.CurrentPage  = page;
            ViewBag.Count        = count;
            ViewBag.Declarations = items;

            return(View());
        }
コード例 #8
0
        public ActionResult UserDeclaration(long?declarationId)
        {
            var declaration = DeclarationRepository.GetById(declarationId);

            ViewBag.Declaration = declaration;


            var countEmptyImages = 6 - declaration.Images.Count;

            for (var i = 0; i < countEmptyImages; i++)
            {
                declaration.Images.Add(new Image
                {
                    Name          = "/ContentImages/null.jpg",
                    DeclarationId = declaration.Id,
                });
            }
            InitDropDownItems(declaration.SubCategory.CategoryId, declaration.City.RegionId);

            return(View(declaration));
        }
コード例 #9
0
        public ActionResult MyDeclarations(DeclarationTypes declarationType = DeclarationTypes.Active, int page = 1)
        {
            var query    = DeclarationRepository.GetDeclarationsByUserId(UserId);
            int pageSize = 5;   // количество элементов на странице

            ViewBag.ActiveCount     = query.Count(x => x.Type == DeclarationTypes.Active);
            ViewBag.ModerationCount = query.Count(x => x.Type == DeclarationTypes.OnModeration);
            ViewBag.RejectedCount   = query.Count(x => x.Type == DeclarationTypes.Rejected);

            switch (declarationType)
            {
            case DeclarationTypes.Active:
                query = query.Where(x => x.Type == DeclarationTypes.Active);
                break;

            case DeclarationTypes.OnModeration:
                query = query.Where(x => x.Type == DeclarationTypes.OnModeration);
                break;

            case DeclarationTypes.Rejected:
                query = query.Where(x => x.Type == DeclarationTypes.Rejected);
                break;
            }

            var count = query.Count();

            var items = query
                        .OrderBy(x => x.CreatedDate)
                        .Skip((page - 1) * pageSize)
                        .Take(pageSize)
                        .ToList();

            ViewBag.DeclarationType = declarationType;
            ViewBag.PageSize        = pageSize;
            ViewBag.CurrentPage     = page;
            ViewBag.Count           = count;
            ViewBag.Declarations    = items;

            return(View());
        }
        public JsonResult CheckDeclarations()
        {
            string FLAG_PROFILE    = "";
            string FLAG_ACADEMIC   = "";
            string FLAG_DOC        = "";
            string FLAG_BACKGROUND = "";

            try
            {
                DeclarationRepository _objRepository = new DeclarationRepository();
                StudentDeclaration    _obj           = new StudentDeclaration();
                _obj.studentid = Session["studentid"].ToString();
                DataSet ds = _objRepository.Check_Declarations(_obj);
                if (ds != null)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        FLAG_PROFILE    = ds.Tables[0].Rows[0]["FLAG_PROFILE"].ToString();
                        FLAG_ACADEMIC   = ds.Tables[0].Rows[0]["FLAG_ACADEMIC"].ToString();
                        FLAG_DOC        = ds.Tables[0].Rows[0]["FLAG_DOC"].ToString();
                        FLAG_BACKGROUND = ds.Tables[0].Rows[0]["FLAG_BACKGROUND"].ToString();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(Json(new
            {
                FLAG_PROFILE = FLAG_PROFILE,
                FLAG_ACADEMIC = FLAG_ACADEMIC,
                FLAG_DOC = FLAG_DOC,
                FLAG_BACKGROUND = FLAG_BACKGROUND
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }
コード例 #11
0
        public ActionResult DeleteDeclaration(int?declarationId)
        {
            DeclarationRepository.Remove(declarationId);

            return(RedirectToAction("MyDeclarations"));
        }
コード例 #12
0
        public ActionResult DeclarationUpdate(Declaration declaration)
        {
            DeclarationRepository.Update(declaration);

            return(RedirectToAction("MyDeclarations"));
        }
コード例 #13
0
        public ActionResult Index(int?idCategory, int?idSubCategory, int page = 1,
                                  SortTypes sortType = SortTypes.ByDate)
        {
            var title    = "Все категории";
            var query    = DeclarationRepository.GetDeclarationsByDeclarationType(DeclarationTypes.Active);
            int pageSize = 5; // количество элементов на странице

            InitDropDownItems();

            if (idCategory != null)
            {
                query = query.Where(x => x.SubCategory.CategoryId == idCategory);
                title = CategoryRepository.GetById(idCategory).Name;
            }
            else if (idSubCategory != null)
            {
                query = query.Where(x => x.SubCategoryId == idSubCategory);
                title = CategoryRepository.GetSubCategoryById(idSubCategory).Name;
            }

            var count = query.Count();

            switch (sortType)
            {
            case SortTypes.ByDate:
                query = query.OrderBy(x => x.CreatedDate);
                break;

            case SortTypes.PriceAsc:
                query = query.OrderBy(x => x.Price);
                break;

            case SortTypes.PriceDesc:
                query = query.OrderByDescending(x => x.Price);
                break;
            }

            var items = query
                        .Skip((page - 1) * pageSize)
                        .Take(pageSize)
                        .ToList();

            var sortItems = new List <SelectListItem>
            {
                new SelectListItem {
                    Value = SortTypes.ByDate.ToString(), Text = "По дате добавления"
                },
                new SelectListItem {
                    Value = SortTypes.PriceAsc.ToString(), Text = "Сначала дешевые"
                },
                new SelectListItem {
                    Value = SortTypes.PriceDesc.ToString(), Text = "Сначала дорогие"
                }
            };
            var sortList = new SelectList(sortItems, "Value", "Text", sortType);

            ViewBag.SortList      = sortList;
            ViewBag.PageSize      = pageSize;
            ViewBag.CurrentPage   = page;
            ViewBag.Count         = count;
            ViewBag.Title         = title;
            ViewBag.Declarations  = items;
            ViewBag.IdCategory    = idCategory;
            ViewBag.IdSubCategory = idSubCategory;

            TempData["IdCategory"]    = idCategory;
            TempData["idSubCategory"] = idSubCategory;

            return(View());
        }
コード例 #14
0
 public UnitofWork(RepositoryContext context)
 {
     _context    = context;
     Declaration = new DeclarationRepository(_context);
     Attachment  = new AttachmentRepository(_context);
 }
コード例 #15
0
        public ActionResult DeclarationSend(int declarationId, DeclarationTypes declarationType)
        {
            DeclarationRepository.EditDeclarationType(declarationId, declarationType);

            return(RedirectToAction("DeclarationList", "Moderator"));
        }
コード例 #16
0
        public ActionResult DeclarationModeration(int?declarationId)
        {
            var declaration = DeclarationRepository.GetById(declarationId);

            return(View(declaration));
        }