public async Task <IActionResult> CreateProfile(CreateProfileInputModel inputModel) { var userId = this.userManager.GetUserId(this.User); // TODO: To edit error messagies in the ViewModel; if (!this.ModelState.IsValid) { inputModel.PhotoUrl = this.usersService.GetUserById <CreateProfileInputModel>(userId).PhotoUrl; var allCategories = new AllCategoriesViewModel { Categories = this.categoriesService.GetAll <CategoryListViewModel>(), }; inputModel.AllCategories = allCategories; return(this.View(inputModel)); } if (inputModel.NewPhoto != null) { inputModel.PhotoUrl = await this.cloudinaryService.UploadPhotoAsync(inputModel.NewPhoto, "User", "Users"); } await this.usersService.CreateAProfileAsync(userId, inputModel.UserName, inputModel.PhotoUrl, inputModel.Email, inputModel.Summary, inputModel.PhoneNumber); await this.categoryUsersServices.CreateAsync(userId, inputModel.CategoriesId); return(this.RedirectToAction(nameof(this.Profile), new { id = userId })); }
public async Task <IActionResult> Post(ProjectPostInputViewModel inputModel) { if (!this.ModelState.IsValid) { var allCategories = new AllCategoriesViewModel { Categories = this.categoriesService.GetAll <CategoryListViewModel>(), }; inputModel.AllCategories = allCategories; return(this.View(inputModel)); } var user = await this.userManager.GetUserAsync(this.User); var usersIds = this.usersService.GetUsersIdsFromEmailsString(inputModel.UsersEmails); var projectId = await this.projectsService.CreateAsync(inputModel.Title, inputModel.Description, user.Id); await this.categoryProjectsServices.CreateAsync(projectId, inputModel.CategoriesId); if (usersIds.Count != 0) { await this.projectOfferUsersServices.CreateAsync(projectId, usersIds); } this.TempData["SuccessPost"] = string.Format(PostSuccessMessage, inputModel.Title); return(this.RedirectToAction("Profile", "Users", new { id = user.Id })); }
public IActionResult AllCategories() { AllCategoriesViewModel model = new AllCategoriesViewModel(); model.EventCategories = eventRepository.GetAllEventCategories().ToList(); return(View(model)); }
public async Task <IActionResult> GetAllCategories() { var model = new AllCategoriesViewModel() { Categories = await this.categoriesService.GetAllAsync <CategoryViewModel>(), }; return(this.View(model)); }
public IViewComponentResult Invoke() { var allCategories = new AllCategoriesViewModel { Categories = this.categoriesService.GetAll <CategoryListViewModel>().OrderBy(c => c.Name), }; return(this.View(allCategories)); }
public IActionResult Index() { var model = new AllCategoriesViewModel() { Categories = this.categoriesService.GetAllCategories(), }; return(this.View(model)); }
public IActionResult Index() { var viewModel = new AllCategoriesViewModel { Categories = this.categoriesService.GetAll <CategoryViewModel>(), }; return(this.View(viewModel)); }
public IActionResult All() { var model = new AllCategoriesViewModel { Categories = this.categoryService .GetAllCategories <CategoryViewModel>(), }; return(this.View(model)); }
public IActionResult Index() { var categories = this.categoriesService.GetAll(); var viewModel = new AllCategoriesViewModel { Categories = categories }; return(View(viewModel)); }
public async Task <IViewComponentResult> InvokeAsync(bool hasToAddSecondCriteria) { var model = new AllCategoriesViewModel() { Categories = await this.categoriesService .GetAllAsync <CategoryViewModel>(), HasToAddSecondCriteria = hasToAddSecondCriteria, }; return(this.View(model)); }
public async Task <IActionResult> ShowCategories() { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var categories = await _categoryService.GetCategories(userId); var vm = new AllCategoriesViewModel { Categories = categories }; return(View(vm)); }
public IViewComponentResult Invoke() { var unorderedCollection = this.categoryService.GetCategoriesName <CategoryMenuViewModel>(); var orderedCollection = this.categoryService.OrderCategories(unorderedCollection, "Starters", "Dressings", "Soups", "Salads", "Main Courses", "Pizza", "Pasta", "Pastry", "Desserts", "Cocktails"); var viewModel = new AllCategoriesViewModel() { Categories = orderedCollection }; return(this.View(viewModel)); }
public IActionResult All(int page = 1) { var allCategories = this.categoryService.All(page); var totalCategories = this.categoryService.Total(); var model = new AllCategoriesViewModel { Categories = allCategories, Total = totalCategories, CurrentPage = page }; return(this.View(model)); }
public IActionResult Post() { var allCategories = new AllCategoriesViewModel { Categories = this.categoriesService.GetAll <CategoryListViewModel>(), }; var modelView = new ProjectPostInputViewModel { AllCategories = allCategories, }; return(this.View(modelView)); }
public IActionResult Index(int?page) { var categories = _categoriesService.GetAllViewModels(); var nextPage = page ?? 1; var pagetCategories = categories.ToPagedList(nextPage, 10); var model = new AllCategoriesViewModel { Categories = pagetCategories }; return(View(model)); }
public IViewComponentResult Invoke() { var model = new AllCategoriesViewModel { BaseCategories = this.baseJobCategoriesRepository.All().To <BaseJobCategoryViewModel>().ToList(), }; model .BaseCategories .Select(x => x.JobCategories.Select(y => this.jobCategoriesRepository .All() .To <JobCategoriesViewModel>() .ToList())); return(this.View(model)); }
public async Task <IActionResult> All(int page = 1) { var viewModel = await this.categoriesService .GetAllCategoriesAsync <CategoryViewModel>(CategoriesPerPage, (page - 1) *CategoriesPerPage); var categoriesCount = await this.categoriesService.GetAllCategoriesCountAsync(); var allCategoriesViewModel = new AllCategoriesViewModel { CurrentPage = page, PagesCount = (int)Math.Ceiling((double)categoriesCount / CategoriesPerPage), Categories = viewModel, }; return(this.View(allCategoriesViewModel)); }
public IActionResult CreateProfile() { var userId = this.userManager.GetUserId(this.User); var modelView = this.usersService.GetUserById <CreateProfileInputModel>(userId); if (modelView == null) { return(this.NotFound()); } var allCategories = new AllCategoriesViewModel { Categories = this.categoriesService.GetAll <CategoryListViewModel>(), }; modelView.AllCategories = allCategories; return(this.View(modelView)); }
public IActionResult All(AllProjectsViewModel viewModel) { var categories = this.categoriesService.GetAll <CategoryListViewModel>(); var allCategories = new AllCategoriesViewModel { Categories = categories, }; viewModel.AllCategories = allCategories; viewModel.AllProjects = this.projectsService.GetAll <ProjectViewModel>(); if (viewModel.SelectedCategoriesId.Count() > 0) { viewModel.AllProjects = viewModel.AllProjects.Where(p => p.CategoriesId.Any(c => viewModel.SelectedCategoriesId.Contains(c))); } viewModel.MostWanted = this.projectsService.GetMostWanted <ProjectTitleAndApplicantsViewModel>(); return(this.View(viewModel)); }
public ActionResult All(int page = 1, string order = "default") { var model = new AllCategoriesViewModel { Categories = categoryService.GetAllByCriteria(order) .Skip((page - 1) * PerPageItems) .Take(PerPageItems) .AsQueryable() .ProjectTo <CategoryViewModel>(Mapper.ConfigurationProvider) .ToList(), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PerPageItems, TotalItems = categoryService.GetCount() } }; ViewBag.Order = order; return(View(model)); }
public IActionResult All(int page = 1) { page = this.CheckIfGivenPageIsBelowOne(page); var categories = this.categoryService.GetAllCategoriesWithPage <DetailsAllCategoriesViewModel>( CategoriesPerPage, (page - 1) * CategoriesPerPage); var count = this.categoryService.GetCountOfAllCategories(); var allCategoriesViewModel = new AllCategoriesViewModel { Categories = categories, CurrentPage = page, PagesCount = (int)Math.Ceiling((double)count / CategoriesPerPage), }; if (allCategoriesViewModel.PagesCount == 0) { allCategoriesViewModel.PagesCount = 1; } return(this.View(allCategoriesViewModel)); }
public ActionResult UpdateExisting([DataSourceRequest]DataSourceRequest request, AllCategoriesViewModel categoryModel) { if (categoryModel != null && ModelState.IsValid) { } var categoryToUpdate = this.Mapper.Map<Category>(categoryModel); var updatedCategory = categories.EditCategory(categoryToUpdate); var result = new[] { updatedCategory }.ToDataSourceResult(request,ModelState); return Json(result); }
public ActionResult EditCategory(AllCategoriesViewModel model) { var categoryToUpdate = this.categories.GetByName(model.Name); categoryToUpdate.Name = model.Name; categoryToUpdate.Description = model.Description; categories.EditCategory(categoryToUpdate); return RedirectToAction("All", "Categories"); }
public ActionResult Delete([DataSourceRequest]DataSourceRequest request,AllCategoriesViewModel categoryModel) { if (categoryModel != null ) { } var categoryToDelete = this.Mapper.Map<Category>(categoryModel); var deletedCategoryRecord = categories.Delete(categoryToDelete); var result = new[] { deletedCategoryRecord }.ToDataSourceResult(request, ModelState); return Json(result); }
public ActionResult Index(int id = 0, int sortingOrder = 0) { ViewBag.SortingOrder = sortingOrder; if (id == 0) { var efRootCategories = _categoryRepository.GetRootCategoriesWithSubs(); var modelRootCategories = AllCategoriesViewModel.ToModelEnumerable(efRootCategories); ViewBag.MetaTitle = "Категории"; return(View("ViewRootCategories", modelRootCategories)); } SearchParamsCategory searchParamsCategory; var curCookieName = this.HttpContext.Request.Cookies.AllKeys.FirstOrDefault(i => i == "category_" + id.ToString()); var curCookie = this.HttpContext.Request.Cookies.Get(curCookieName); CategoryViewModel viewModel; if (curCookie != null) { var jsonObj = JsonConvert.DeserializeObject <CategoryFiltersJsonModel>(curCookie.Value); var checkedEnumValueIds = new List <int>(); var filterSearchModel = new List <FilterSearchModel>(); foreach (var item in jsonObj.Filters) { filterSearchModel.Add(new FilterSearchModel() { Id = item.Id, EventValueIds = item.EnumValueIds, }); checkedEnumValueIds.AddRange(item.EnumValueIds); } searchParamsCategory = new SearchParamsCategory(null, id, (int)jsonObj.MaxPrice, (int)jsonObj.MinPrice, filterSearchModel); viewModel = CategoryViewModel.ToModel(_categoryRepository.GetBySearchParams(searchParamsCategory)); viewModel.CurrentMaxPrice = (int)jsonObj.MaxPrice; viewModel.CurrentMinPrice = (int)jsonObj.MinPrice; foreach (var item in viewModel.Filters) { foreach (var enumVal in item.EnumValues) { if (checkedEnumValueIds.Contains(enumVal.Id)) { enumVal.Checked = true; } } } } else { searchParamsCategory = new SearchParamsCategory(id) { IsSearchOnlyPublicProduct = true }; var t = _categoryRepository.GetBySearchParams(searchParamsCategory); viewModel = CategoryViewModel.ToModel(t); } //var productsEnumValues = new List<int>(); //foreach (var item in viewModel.Products) //{ // productsEnumValues.AddRange(item.EnumValues.Select(s => s.Id)); //} foreach (var item in viewModel.Filters) { item.EnumValues = (item.EnumValues).Where(w => searchParamsCategory.OutEnumValueIds.Contains(w.Id)).OrderBy(o => o, new Tools.Compare.CompareCategoryEnumValueViewModel()).ToList(); } viewModel.ExistProducts = searchParamsCategory.ExistProductsInBd; if (sortingOrder != 0) { switch (sortingOrder) { case (int)Common.TypeSort.Price: viewModel.Products.Sort(new Tools.Compare.ProductCompareByPrice()); break; case (int)Common.TypeSort.Name: viewModel.Products.Sort(new Tools.Compare.ProductCompareByTitle()); break; case (int)Common.TypeSort.Popular: viewModel.Products.Sort(new Tools.Compare.ProductCompareByPopular()); break; default: break; } } var tmpBreadCrumbs = _categoryRepository.GetBreadCrumbs(id); if (tmpBreadCrumbs.Count() == 2) { foreach (var item in tmpBreadCrumbs) { var tmpIndx = item.FriendlyUrl.LastIndexOf('/'); if (tmpIndx != 0) { item.FriendlyUrl = item.FriendlyUrl.Substring(0, tmpIndx); } break; } } ViewBag.BredCrumbs = tmpBreadCrumbs; viewModel.NestedCategories = _categoryRepository.GetNestedCategories(id).Select(s => CategoryShortViewModel.ToModel(s)).ToList(); viewModel.MaxPrice = _categoryRepository.GetMaxPriceFromCategory(id); viewModel.MinPrice = _categoryRepository.GetMinPriceFromCategory(id); ViewBag.MetaTitle = viewModel.Seo != null ? viewModel.Seo.MetaTitle : viewModel.Title; ViewBag.Keywords = viewModel.Seo != null ? viewModel.Seo.MetaKeywords : null; ViewBag.Description = viewModel.Seo != null ? viewModel.Seo.MetaDescription : null; bool WillBeAddedFlag = viewModel.Products.Any(i => i.TypeStatusProduct == Common.TypeStatusProduct.WillBeAdded); ViewBag.WillBeAddedFlag = WillBeAddedFlag; if (WillBeAddedFlag) { ViewBag.WillBeAddedFlagText = _globalRepository.Get("footnote"); } return(View(viewModel)); }