/// <summary> /// Gets the type of the home model by city and. /// Initializes a new instance of the <see cref="HomeModel"/> class. /// 这里,是分类型查询景区信息的 type.cshtml /// </summary> /// <param name="city">The city.</param> /// <param name="type">The type.</param> /// <param name="b">if set to <c>true</c> [b].</param> /// <param name="pageIndex">Index of the page.</param> /// <param name="pageSize">Size of the page.</param> /// <returns></returns> public HomeDto GetHomeModelByCityAndType(string city, int?type, bool b, int?pageIndex, int?pageSize) { HomeDto data = new HomeDto(); //这个地方,在调试详细页的时候,会出现一个city = image的东西,不知道是从那里来的 data.CurrentClassId = (int)type; //得到当前的访问者信息 data.LocationSina = sinaInfoService.GetSinaInfo(); data.LocaltionCityInfo = cityInfoService.GetCityInfoBySina(data.LocationSina); //在这里,我们得将city(拼音的)转换成中文的 data.CurrentCityInfo = cityInfoService.GetSingleCityInfo(string.Empty, city); int total = 0; int sortCount = 0; int currentClassId = 0; List <TopClassDto> topClass = null; //得到传入城市的景区信息 //这个地方的 province ,的那个得是中文的 List <DefaultSightInfoDto> si = sightInfoService.GetSightListByProvinceOrCity(data.LocationSina, ref currentClassId, data.CurrentCityInfo.province, data.CurrentCityInfo.city, type, pageIndex, pageSize, ref total, ref sortCount, ref topClass); data.SightInfo = sightInfoService.ToPageList(si, (int)pageIndex, (int)pageSize, total - sortCount); data.TopClass = topClass; data.CurrentClassId = currentClassId; return(data); }
public async Task <IActionResult> Index() { var services = await _repo.GetServices(); var announces = await _repo.GetAnnounces(); var userComments = await _repo.GetComments(); var homeDto = new HomeDto { Services = services.Select(a => new ServiceDto { Id = a.Id, ServiceName = a.ServiceName, ServiceDescription = a.ServiceDescription, ServicePhotoPath = a.ServicePhotoPath, ServiceSubHeader = a.ServiceSubHeader }).ToList(), Announcements = announces.Select(a => new AnnouncementDto { AnnounceContent = a.AnnounceContent, AnnounceHeader = a.AnnounceHeader, AnnouncePhotoPath = a.AnnouncePhotoPath }).ToList(), UserComments = userComments.Select(a => new UserCommentsDto { CommentText = a.CommentText, UserFullName = a.UserFullName }).ToList() }; return(View(homeDto)); }
async Task <HomeDto> GetHomeAsync(string path) { HttpClient client = new HttpClient(); // Update port # in the following line. var baseUrl = HttpContext.Request.Host.Value.IndexOf("localhost") > -1 ? _config.GetValue <string>("HttpUrl:LocalHost") : _config.GetValue <string>("HttpUrl:Tracing"); client.BaseAddress = new Uri(baseUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); HomeDto home = null; HttpResponseMessage response = await client.GetAsync(path); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); home = JsonConvert.DeserializeObject <HomeDto>(content); } return(home); }
public async Task <HomeDto> GetHomeMetaData() { HomeDto homeDto = new HomeDto(); homeDto.RequestsHome.Pending = (await _requestRepository.CountAsync(x => x.StatusId == (int)RequestStatusEnum.PENDING)); homeDto.RequestsHome.Approved = (await _requestRepository.CountAsync(x => x.StatusId == (int)RequestStatusEnum.APPROVED)); homeDto.RequestsHome.Declined = (await _requestRepository.CountAsync(x => x.StatusId == (int)RequestStatusEnum.DECLINED)); homeDto.RequestsHome.Processed = (await _requestRepository.CountAsync(x => x.StatusId == (int)RequestStatusEnum.PROCESSED)); homeDto.InstallationsHome.InstallationsActive = (await _installationsRepository.CountAsync(x => x.Status == (int)InstallationStatusEnum.ACTIVE)); homeDto.InstallationsHome.InstallationsInactive = (await _installationsRepository.CountAsync(x => x.Status == (int)InstallationStatusEnum.INACTIVE)); homeDto.InstallationsHome.InstallationsMalfunction = (await _installationsRepository.CountAsync(x => x.Status == (int)InstallationStatusEnum.MALFUNCTION)); homeDto.InstallationsHome.InstallationsTotal = await _installationsRepository.CountAsync(); var insights = _requestRepository.GetAllIncluding(x => x.City).ToList() .GroupBy(x => x.CityId) .Select(x => new RequestsInsightHome { RequestsCount = x.Count(), City = ObjectMapper.Map <CitiesDto>(_citiesRepository.Get(x.First().CityId)) }) .ToList(); homeDto.InsightHome = insights; return(homeDto); }
public ActionResult Province(string prov, string city, int?cla, int?id) { HomeDto data = null; var pi = (id == null ? 1 : (int)id); string cityCopy = string.Empty; if (city != "all") { cityCopy = city; } if (string.IsNullOrEmpty(prov)) { data = homeService.GetHomeModelNoCity(id ?? 1, pageSize); return(View(data)); } else { data = homeService.GetHomeModelByProvAndCityAndType(prov, cityCopy, cla ?? 0, pi, 9); if (Request.IsAjaxRequest()) { return(PartialView("ProvincePartial", data)); } return(View(data)); } }
public ViewResult Index() { var transactions = _transactionRepository.GetAllTransactions(GetCurrentUser()).ToList(); var accounts = _accountRepository.GetAllAccounts(GetCurrentUser()); var model = new HomeDto { Transactions = transactions, Accounts = accounts }; return(View(model)); }
public ValuesControllerTest() { _mapper = MapperMock.MapperProfileTest(); _appReo = new AppRepositoryFake(); _controller = new ValuesController(_appReo, _mapper); _newHome = new HomeDto() { Id = 4, Name = "Test", City = "Liverpool", Address = "7 Street", Email = "*****@*****.**", Rating = 5 }; }
public async Task <IActionResult> AddHome(HomeDto homeDto) { if (await _appRepository.CheckHomeName(homeDto.Name)) { return(BadRequest($"Home {homeDto.Name.ToUpper()} already exists in database.")); } var home = _mapper.Map <Home>(homeDto); _appRepository.Add(home); await _unitOfWork.SaveAll(); return(Ok(home)); }
public async Task <IActionResult> Post(HomeDto homeDto) { if (ModelState.IsValid) { var home = _mapper.Map <Homes>(homeDto); var newHome = _appRepo.Add(home); await _appRepo.SaveAllAsync(); return(Ok(home)); } return(BadRequest("Validation error")); }
public ActionResult Index(string city, int?id) { HomeDto data = null; var pi = id == null ? 1 : (int)id; if (string.IsNullOrEmpty(city) || string.Compare(city, "scripts", false) == 0) { data = homeService.GetHomeModelNoCity(pi, pageSize); } else { data = homeService.GetHomeModelByCity(city, pi, pageSize); } return(View(data)); }
public ViewResult Type(string city, int?cla, int?id) { HomeDto data = null; var pi = (id == null ? 1 : (int)id); if (string.IsNullOrEmpty(city)) { data = homeService.GetHomeModelNoCity(pi, pageSize); } else { data = homeService.GetHomeModelByCityAndType(city, cla ?? 0, true, pi, pageSize); } return(View(data)); }
public IHttpActionResult CreateHome(HomeDto homeDto) { if (!ModelState.IsValid) { return(BadRequest()); } var home = Mapper.Map <HomeDto, Home>(homeDto); _context.Homes.Add(home); _context.SaveChanges(); homeDto.Id = home.Id; return(Created(new Uri(Request.RequestUri + "/" + home.Id), homeDto)); }
public HomeDto GetHomeDto(int amount, int frontAmount) { var repo = _uow.GetGenericRepository<Product>(); var _discount = repo.GetAll().Take(1).ToList()[0]; // instead of 5 choose a (maybe random) category with has a product with a discount var _products = repo.GetAll().Take(amount).ToList(); var _frontImages = repo.GetAll().Take(frontAmount + 1).ToList(); if (_products == null || _frontImages == null || _discount == null) return null; DiscountImage discountImage = new DiscountImage { CategoryName = _discount.Category, DiscountAmount = (int)Math.Floor((_discount.DiscountedPrice * 100) / _discount.Price), // calculate percentage ImageUrl = _uow.GetGenericRepository<ImageUri>().FirstOrDefault(y => y.ProductId == _discount.Id).Uri, Url = "https://localhost:5001/category/" + _discount.Category }; IEnumerable<SimpleProduct> simpleProducts = _products == null ? null : _products.Select(x => new SimpleProduct { Name = x.Name, ImageUrl = _uow.GetGenericRepository<ImageUri>().FirstOrDefault(y => y.ProductId == x.Id).Uri, Url = "https://localhost:5001/product?id=" + x.Id, OriginalPrice = x.Price, DiscountedPrice = x.DiscountedPrice, StatusClass = "NEW" // TODO MAKE STATUS CLASS IN PRODUCT }).ToList(); IEnumerable<FrontImage> frontImages = _frontImages == null ? null : _frontImages.Select(x => new FrontImage { BackgroundImageUrl = _uow.GetGenericRepository<ImageUri>().FirstOrDefault(y => y.ProductId == x.Id).Uri, Title = x.Name, Text = x.DescriptionMain // or desription extra? }).ToList(); var homeDto = new HomeDto { DiscountImage = discountImage, FrontImages = frontImages.Take(frontAmount), FrontImage = frontImages.Last(), Products = simpleProducts, }; return homeDto; }
public ViewResult Details(int?id) { Employee employee = _employeeRepository.GetEmployee(id.Value); if (employee == null) { Response.StatusCode = 400; return(View("EmployeeNotFound", id.Value)); } HomeDto homeDto = new HomeDto() { Employee = employee, PageTitle = "Employee Details" }; return(View(homeDto)); }
public IActionResult Index() { var testObjs = _readOnlyRepository.Table <Test, Guid>(); var viewObj = new HomeDto(); viewObj.NameValues = new List <TestDto>(); foreach (var testObj in testObjs) { viewObj.NameValues.Add(new TestDto() { Name = testObj.Name, Value = testObj.Value }); } return(View(viewObj)); }
public ActionResult SelectProvinceByTicket(string prov, int?cla, int?start, int?end, int?id) { HomeDto data = null; var pi = (id == null ? 1 : (int)id); if (string.IsNullOrEmpty(prov)) { data = homeService.GetHomeModelNoCity(pi, pageSize); return(View(data)); } else { data = homeService.GetHomeModelByProvAndCityAndTicket(prov, cla ?? 0, start, end, id ?? 1, 9); if (Request.IsAjaxRequest()) { return(PartialView("ProvincePartial", data)); } return(View(data)); } }
public IComandoResultado ObterDadosDashboard() { var dashboard = new HomeDto { QuantidadeDeJogos = JogoNegocio.ListarTodosOsJogosAsync().Result.Count(), UsuariosCadastrados = UsuarioNegocio.ListarTodosOsUsuariosAsync().Result.Count(u => u.Status.Equals(1)) }; var jogosEmprestados = JogoNegocio.ListarTodosOsJogosAsync().Result.Count(j => j.SituacaoId == 2); if (dashboard.QuantidadeDeJogos != 0 && jogosEmprestados != 0) { dashboard.PorcentagemDeEmprestimo = dashboard.QuantidadeDeJogos / jogosEmprestados; } else { dashboard.PorcentagemDeEmprestimo = 0; } return(new ComandoResultado(true, "Efetuado com sucesso.", dashboard)); }
public IHttpActionResult UpdateHome(int id, HomeDto homeDto) { if (!ModelState.IsValid) { return(BadRequest()); } var homeInDb = _context.Homes.SingleOrDefault(c => c.Id == id); if (homeInDb == null) { return(NotFound()); } Mapper.Map(homeDto, homeInDb); _context.SaveChanges(); return(Ok()); }
/// <summary> /// Gets the home model by city. /// Initializes a new instance of the根据传入的城市选 <see cref="HomeModel"/> class. /// </summary> /// <param name="city">The city.拼音哦</param> /// <param name="pi">The pi.</param> /// <param name="pageSize">The take.</param> /// <returns></returns> public HomeDto GetHomeModelByCity(string city, int pi, int pageSize) { HomeDto data = new HomeDto(); data.LocationSina = sinaInfoService.GetSinaInfo(); data.LocaltionCityInfo = cityInfoService.GetCityInfoBySina(data.LocationSina); data.CurrentCityInfo = cityInfoService.GetSingleCityInfo(string.Empty, city); int total = 0; int sortCount = 0; int currentClassId = 0; List <TopClassDto> topClass = null; //得到传入城市的景区信息 List <DefaultSightInfoDto> si = sightInfoService.GetSightListByProvinceOrCity(data.LocationSina, ref currentClassId, string.Empty, data.CurrentCityInfo.city, -1, pi, pageSize, ref total, ref sortCount, ref topClass); data.SightInfo = sightInfoService.ToPageList(si, pi, pageSize, total - sortCount); data.TopClass = topClass; data.CurrentClassId = currentClassId; return(data); }
public IActionResult Index(string category) { List <PostDto> posts = new List <PostDto>(); if (category != null) { posts = PostService.GetPosts(category); } else { posts = PostService.GetPosts(null); } List <CategoryDto> categories = CategoryService.GetCategoriesDto(); HomeDto homeview = new HomeDto { CategoryDto = categories, PostDto = posts }; return(View(homeview)); }
/// <summary> /// Gets the home model by prov and city and ticket. /// </summary> /// <param name="prov">The prov.</param> /// <param name="type">The type.</param> /// <param name="start">The start.</param> /// <param name="end">The end.</param> /// <param name="pageIndex">Index of the page.</param> /// <param name="pageSize">Size of the page.</param> /// <returns></returns> public HomeDto GetHomeModelByProvAndCityAndTicket(string prov, int?type, int?start, int?end, int?pageIndex, int?pageSize) { HomeDto data = new HomeDto(); data.CurrentClassId = (int)type; //得到当前的访问者信息 data.LocationSina = sinaInfoService.GetSinaInfo(); data.LocaltionCityInfo = cityInfoService.GetCityInfoBySina(data.LocationSina); //在这里,我们得将city(拼音的)转换成中文的 data.CurrentCityInfo = cityInfoService.GetSingleCityInfo(prov, string.Empty); int total = 0; int sortCount = 0; List <TopClassDto> topClass = null; //省的中文名查询哈 List <DefaultSightInfoDto> si = sightInfoService.GetSightListByTicket(data.CurrentCityInfo.province, start, end, (int)pageIndex, (int)pageSize, ref total, ref sortCount, ref topClass); // this.TopClass = Querys.GetTopClassBySight(si); data.SightInfo = sightInfoService.ToPageList(si, (int)pageIndex, (int)pageSize, total - sortCount); data.TopClass = topClass; return(data); }
/// <summary> /// Gets the type of the home model by prov and city and. /// Initializes a new instance of the 拼音哈<see cref="HomeModel"/> class. /// </summary> /// <param name="province">The province.</param> /// <param name="city">The city.</param> /// <param name="type">The type.</param> /// <param name="pageIndex">Index of the page.</param> /// <param name="pageSize">Size of the page.</param> /// <returns></returns> public HomeDto GetHomeModelByProvAndCityAndType(string province, string city, int?type, int?pageIndex, int?pageSize) { HomeDto data = new HomeDto(); data.CurrentClassId = (int)type; //得到当前的访问者信息 data.LocationSina = sinaInfoService.GetSinaInfo(); data.LocaltionCityInfo = cityInfoService.GetCityInfoBySina(data.LocationSina); //在这里,我们得将city(拼音的)转换成中文的 data.CurrentCityInfo = cityInfoService.GetSingleCityInfo(province, city); int total = 0; int sortCount = 0; int currentClassId = 0; List <TopClassDto> topClass = null; List <DefaultSightInfoDto> si = null; if (string.IsNullOrEmpty(city)) { //得到传入城市的景区信息 //这个地方的 province ,的那个得是中文的 si = sightInfoService.GetSightListByProvinceOrCity(data.LocationSina, ref currentClassId, data.CurrentCityInfo.province, string.Empty, type, pageIndex, pageSize, ref total, ref sortCount, ref topClass); } else { //得到传入城市的景区信息 //这个地方的 province ,的那个得是中文的 si = sightInfoService.GetSightListByProvinceOrCity(data.LocationSina, ref currentClassId, data.CurrentCityInfo.province, data.CurrentCityInfo.city, type, pageIndex, pageSize, ref total, ref sortCount, ref topClass); } // this.TopClass = Querys.GetTopClassBySight(si); data.SightInfo = sightInfoService.ToPageList(si, (int)pageIndex, (int)pageSize, total - sortCount); data.TopClass = topClass; data.CurrentClassId = currentClassId; return(data); }
/// <summary> /// Initializes a new instance of the 根据当前IP中的市选景区<see cref="HomeModel"/> class. /// </summary> /// <param name="pi">The pi.</param> /// <param name="pageSize">The take.</param> /// <returns></returns> public HomeDto GetHomeModelNoCity(int pi, int pageSize) { HomeDto data = new HomeDto(); data.LocationSina = sinaInfoService.GetSinaInfo(); data.LocaltionCityInfo = cityInfoService.GetCityInfoBySina(data.LocationSina); //在这里,我们得将city(拼音的)转换成中文的 data.CurrentCityInfo = data.LocaltionCityInfo; int total = 0; int sortCount = 0; int currentClassId = 0; List <TopClassDto> topClass = null; //默认是当前的IP地址来选景区 //传入当前地址 //在这个里面,更新了TopClass List <DefaultSightInfoDto> si = sightInfoService.GetSightListByProvinceOrCity(data.LocationSina, ref currentClassId, string.Empty, data.LocationSina.City, -1, pi, pageSize, ref total, ref sortCount, ref topClass); data.SightInfo = sightInfoService.ToPageList(si, 1, pageSize, total - sortCount); data.TopClass = topClass; data.CurrentClassId = currentClassId; return(data); }
public async Task <ActionResult <HomeDto> > Get() { var top = 6; var today = DateTime.Now; var upcomingRealeases = await context.Movies .Where(x => x.ReleaseDate > today) .OrderBy(x => x.ReleaseDate) .Take(top) .ToListAsync(); var inTheaters = await context.Movies .Where(x => x.InTheaters) .OrderBy(x => x.ReleaseDate) .Take(top) .ToListAsync(); var homeDto = new HomeDto(); homeDto.UpcomingReleases = mapper.Map <List <MovieDto> >(upcomingRealeases); homeDto.InTheaters = mapper.Map <List <MovieDto> >(inTheaters); return(homeDto); }
public IHttpActionResult GetDistrict(HomeDto dto) { var districts = _context.GetDistricts(dto.ProvinceId); return(Ok(districts)); }