public async Task <IActionResult> Create(CreateDashboardViewModel model) { if (!ModelState.IsValid) { return(View(model)); } DashboardDto dashboardDto = _mapper.Map <CreateDashboardViewModel, DashboardDto>(model); if (model.IconFile != null) { dashboardDto.IconId = await _iconManager.CreateAndGetIconId(model.IconFile); } dashboardDto.AppUserId = _userManager.GetUserId(User); var res = _dashboardManager.Create(dashboardDto).Result; if (res != null) { DashboardViewModel dashmodel = _mapper.Map <DashboardDto, DashboardViewModel>(res); if (!dashmodel.IsPublic) { dashmodel.DashCreatorUserName = User.Claims.ElementAt(1).Value; } return(ViewComponent("DashboardElement", dashmodel)); } else { //ModelState.AddModelError(res.Property, res.Message); return(View(model)); } }
private async Task <DashboardDto> GetDashboardDto(string tags, bool?readCache) { try { var weather = await _weatherProvider.Execute(); var photos = await _photoProvider.Execute( string.IsNullOrEmpty(tags)? "landscape" : tags, readCache ?? true); var dashboardDto = new DashboardDto { Photos = photos.Shuffle().Take(20).ToArray(), Quotes = _quoteRepository.GetQuotes("inspirational,motivational").Shuffle().Take(20).ToArray(), Weather = weather }; return(dashboardDto); } catch (Exception e) { _logger.LogError("Error getting DashboardDto", e); throw; } }
internal DashboardDto GetTodayTasks() { List <MyListWithCountDto> list = new List <MyListWithCountDto>(); using (var command = db.Database.GetDbConnection().CreateCommand()) { command.CommandText = "select l.my_list_id, l.title, Count(t.done) from my_tasks t right join my_lists l on l.my_list_id=t.my_list_id where t.done=false group by l.my_list_id, l.title order by l.my_list_id"; db.Database.OpenConnection(); using (var result = command.ExecuteReader()) { while (result.Read()) { list.Add(new MyListWithCountDto() { Id = result.GetInt32(0), Title = result.IsDBNull(1) ? null : result.GetString(1), CountOfNoDoneTasks = result.GetInt32(2) }); } } } DashboardDto outp = new DashboardDto() { CountOfToadyTasks = db.MyTasks.Where(b => b.DoDate.Value.Date == DateTime.Today.Date).Count(), MyListsNoDone = list }; return(outp); }
public DashboardDto GetDashboard() { DashboardDto dashboard = new DashboardDto(); try { // get errors count dashboard.Errors = _applicationDbContext.Logs.Where(e => e.LogType == LogType.Error && e.DateCreated >= DateTime.Now.AddHours(-24)).Count(); // get users count dashboard.Users = _applicationDbContext.Users.Count(); // get lastest post comments count var lastPost = _applicationDbContext.Posts.LastOrDefault(); var commentCount = _applicationDbContext.Comments.Where(c => c.PostId == lastPost.PostId).Select(c => c).Count(); dashboard.Comments = commentCount; //.Comments.Count(); //get posts count dashboard.Posts = _applicationDbContext.Posts.Count(); } catch (Exception ex) { _loggerRepository.Write(ex); } return(dashboard); }
public DashboardDto GetDashboardData() { DashboardDto dashboardDto = new DashboardDto(); dashboardDto.deviceLogDtoList = _deviceLogAdapter.GetAllDeviceLog(); dashboardDto.deviceLogDto = _deviceLogAdapter.GetTopFirstDeviceLog(); return(dashboardDto); }
public DashboardDto Fetch() { var result = new DashboardDto(); result.ProjectCount = db.Projects.Count(); result.OpenProjectCount = db.Projects.Where(r => r.Ended == null).Count(); result.ResourceCount = db.Resources.Count(); return(result); }
public DashboardDto Fetch() { var result = new DashboardDto(); // open database context result.ProjectCount = MockDb.Projects.Count(); result.OpenProjectCount = MockDb.Projects.Where(r => r.Ended == null).Count(); result.ResourceCount = MockDb.Resources.Count(); return(result); }
public DashboardDto GetData() { DashboardDto dto = new DashboardDto { TotalTasks = _taskService.GetTasks().ToList().Count, TotalUsers = _userManager.Users.ToList().Count }; return(dto); }
// GET: Dashboard public ActionResult Index() { DashboardDto dashboard = new DashboardDto(); WCFProxy.Using((delegate(IDashboardService client) { dashboard = client.getDashboard(); })); return(View(dashboard)); }
public IActionResult GetDashboard() { var dto = new DashboardDto { Count = _todoItemService.Dashboard(), TodoLists = _todoListService.Dashboard().ToList() }; return(Ok(dto)); }
/// <summary> /// Updates a dashboard. /// </summary> /// <param name="dashboardDto"></param> /// <returns></returns> public async Task <DashboardDto> UpdateAsync(DashboardDto dashboardDto) { dashboardDto.Name = dashboardDto.Name.SpaceFix(); dashboardDto.Modified = DateTime.Now; dashboardDto.Modifier = "Имя обновившего клиента"; var dashboardDb = _mapper.Map <DashboardDb>(dashboardDto); await _repository.UpdateAsync(dashboardDb).ConfigureAwait(false); return(dashboardDto); }
public HttpResponseMessage Update(DashboardDto reportDto) { var handler = new DashboardUpdateHandler(); var response = handler.Handle(reportDto); if (handler.Errors == null || handler.Errors.Count < 1) { return(Request.CreateResponse(HttpStatusCode.OK, response.DashboardDtos[0])); } return(Request.CreateResponse(HttpStatusCode.BadRequest, handler.Errors)); }
public Dashboard DtoToDashboard(DashboardDto dto) { var dashboard = new Dashboard(); dashboard.ComponentIds = dto.ComponentIds; dashboard.Id = dto.Id; dashboard.Title = dto.Title; dashboard.CreationDate = dto.CreationDate; dashboard.ModificationDate = dto.ModificationDate; return(dashboard); }
public DashboardDto DashboardToDto(Dashboard dashboard) { var dto = new DashboardDto(); dto.ComponentIds = dashboard.ComponentIds; dto.Id = dashboard.Id; dto.Title = dashboard.Title; dto.CreationDate = dashboard.CreationDate; dto.ModificationDate = dashboard.ModificationDate; return(dto); }
public IActionResult Index() { var model = new DashboardDto { Habitats = _habitatService.GetHabitats().Count(), Animals = _animalService.GetAnimals().Count(), Employees = _employeeService.GetEmployees().Count() }; return(View(model)); }
public DashboardDto GetDashboard() { Random random = new Random(); DashboardDto dashboard = new DashboardDto(); dashboard.A = random.Next(60, 100); dashboard.B = random.Next(100, 200); dashboard.C = random.Next(200, 500); dashboard.D = random.Next(500, 1000); return(dashboard); }
public DashboardDto Fetch() { var result = new DashboardDto(); using (var ctx = ObjectContextManager <PTrackerEntities> .GetManager("PTrackerEntities")) { result.ProjectCount = ctx.ObjectContext.Projects.Count(); result.OpenProjectCount = ctx.ObjectContext.Projects.Where(r => r.Ended == null).Count(); result.ResourceCount = ctx.ObjectContext.Resources.Count(); } return(result); }
public async Task <DashboardDto> GetAll(string city = null) { var result = new DashboardDto() { Cities = await _locationRepository.GetAll().GroupBy(x => x.City).Select(x => x.Key).ToListAsync(), AvailabilityData = await GetAvailabilityData(), BookUserComparisonData = await GetBookUserData(city), LocationData = await GetLocationData(city) }; return(result); }
public override DashboardResponse HandleCore(int request) { var mapping = new Mapping(); DashboardDto toDelete = mapping.DashboardToDto(_repository.Get(request)); var componentRepository = new DashboardComponentRepository(); foreach (var id in toDelete.ComponentIds) { componentRepository.Remove(id); } _repository.Remove(request); return(new DashboardResponse(toDelete)); }
private async Task <DashboardDto> GetDashboardDto(IEnumerable <VDashboardExam> list) { DashboardDto dto = new DashboardDto(); if (list != null && list.Any()) { foreach (var item in list) { BuildSchoolYear(dto.SchoolYears, item); } } return(dto); }
public async Task <IActionResult> GetDashboardData(int id) { var date = DateTime.Today.AddDays(-27).Date; var transactions = await _context.Transactions.Where(a => a.Date.Date >= date) .ToListAsync(); DashboardDto dashboardDto = new DashboardDto() { Expense = new List <decimal>(), Income = new List <decimal>(), Net = new List <decimal>() }; for (int i = 0; i < 28; i++) { var exp = transactions.Where(a => a.Date.Date == date.AddDays(i).Date).Sum(a => a.Credit); var inc = transactions.Where(a => a.Date.Date == date.AddDays(i).Date).Sum(a => a.Debit); var net = inc - exp; dashboardDto.Expense.Add(exp); dashboardDto.Income.Add(inc); dashboardDto.Net.Add(net); } var productionOrders = await _context.ProductionOrderHeaders.Where(a => a.RequiredDate == DateTime.Today.Date).ToListAsync(); dashboardDto.OrderReceived = productionOrders.Where(a => !(a.isProcessed.HasValue && a.isProcessed.Value == 1)).Count(); dashboardDto.MaxOrders = productionOrders.Count(); dashboardDto.OrdersHandled = productionOrders.Where(a => a.IsNotEditable == true && (a.isProcessed.HasValue && a.isProcessed == 0)).Count(); dashboardDto.MaxOrdersToHandle = productionOrders.Where(a => a.IsNotEditable == true).Count(); var reOrderCount = 0; var reorderMax = 0; getReorderCount(out reOrderCount, out reorderMax); dashboardDto.MaxItems = reorderMax; dashboardDto.Reorders = reOrderCount; var workersmax = _context.Employees.Where(a => a.IsDeleted == false && a.IsNotActive == false).Count(); var workersCount = _context.Routines.Where(a => a.Date.Date == DateTime.Today.Date && a.StartTime <= DateTime.Now.TimeOfDay && a.EndTime >= DateTime.Now.TimeOfDay).Count(); dashboardDto.workersMax = workersmax; dashboardDto.workers = workersCount; return(Ok(dashboardDto)); }
public async Task <ActionResult> Dashboard() { Student dbStudent = await GetLoggedInStudent(); List <Exam> grades = await(from dbSubjects in db.Subjects.Where(x => x.StudentId == dbStudent.Id) join dbExams in db.Exams.Where(x => x.Grade != Grade.Pet) on dbSubjects.Id equals dbExams.SubjectId select dbExams).ToListAsync(); decimal averageGrades = 0; if (grades.Any()) { averageGrades = (decimal)grades.GroupBy(x => x.SubjectId).Select(x => x.Max(y => y.Grade.ToNumber())).Average(); } List <Subject> subjectsPassed = await(from dbSubjects in db.Subjects.Where(x => x.StudentId == dbStudent.Id) join dbExams in db.Exams.Where(x => x.Grade != Grade.Pet) on dbSubjects.Id equals dbExams.SubjectId select dbSubjects).GroupBy(x => x.Id).Select(x => x.FirstOrDefault()).ToListAsync(); List <Subject> subjectsUnpassed = await(from dbSubjects in db.Subjects.Where(x => x.StudentId == dbStudent.Id) join dbExams in db.Exams.Where(x => x.Grade == Grade.Pet) on dbSubjects.Id equals dbExams.SubjectId into se from dbExams in se.DefaultIfEmpty() select dbSubjects).GroupBy(x => x.Id).Select(x => x.FirstOrDefault()).ToListAsync(); subjectsUnpassed = subjectsUnpassed.DistinctDisunionBy(subjectsPassed, x => x.Id).ToList(); List <Subject> subjects = new List <Subject>(); subjects.AddRange(subjectsPassed); subjects.AddRange(subjectsUnpassed); List <Exam> examPassed = await db.Exams.Where(x => x.Grade != Grade.Pet && x.StudentId == dbStudent.Id).ToListAsync(); List <Exam> examUnpassed = await db.Exams.Where(x => x.Grade == Grade.Pet && x.StudentId == dbStudent.Id).ToListAsync(); DashboardDto dashboardDto = new DashboardDto() { Subjects = subjects, GradeAverage = averageGrades, UnpassedSubjects = subjectsUnpassed, UnpassedExams = examUnpassed, PassedSubjects = subjectsPassed, PassedExams = examPassed }; return(View(dashboardDto)); }
/// <summary> /// Creates a dashboard. /// </summary> /// <param name="dashboardDto"></param> /// <returns></returns> public async Task <DashboardDto> CreateAsync(DashboardDto dashboardDto) { dashboardDto.Id = Guid.NewGuid().ToString(); dashboardDto.Created = DateTime.Now; dashboardDto.Modified = DateTime.Now; dashboardDto.Creator = "Виталий"; dashboardDto.Modifier = "Виталий"; dashboardDto.Name = dashboardDto.Name.SpaceFix(); var dashboardDb = _mapper.Map <DashboardDb>(dashboardDto); await _repository.CreateAsync(dashboardDb).ConfigureAwait(false); return(dashboardDto); }
public IHttpActionResult CreateDashboard(DashboardDto dashboardDto) { if (!ModelState.IsValid) { return(BadRequest()); } var dashboard = Mapper.Map <DashboardDto, Dashboard>(dashboardDto); _context.Dashboards.Add(dashboard); _context.SaveChanges(); dashboardDto.Id = dashboard.Id; return(Created(new Uri(Request.RequestUri + "/" + dashboard.Id), dashboardDto)); }
public async Task <DashboardDto> Update(DashboardDto dashboardDto) { Dashboard dashboard = mapper.Map <DashboardDto, Dashboard>(dashboardDto); try { await unitOfWork.DashboardRepo.Update(dashboard); unitOfWork.Save(); } catch (Exception) { return(null); } return(mapper.Map <Dashboard, DashboardDto>(dashboard)); }
public async Task <ActionResult <DashboardDto> > GetDashboardData([FromQuery] LatLonParameters latLonParameters) { BeachConditionsDto beachConditions = null; try { beachConditions = await _weatherService.GetBeachConditions(); } catch (Exception e) { _logger.LogWarning("Beach Conditions could not be grabbed: " + e.Message); } var uvDto = await _weatherService.GetCurrentUVIndex(latLonParameters); var weatherData = await _weatherService.GetWeather(latLonParameters); var usersFromRepo = await _beachBuddyRepository.GetUsers(); var dashboardDto = new DashboardDto { BeachConditions = beachConditions, DashboardUvDto = _mapper.Map <DashboardUVDto>(uvDto), // Todo: this can be deleted // DashboardUvDto = new DashboardUVDto // { // uv = 8.3, // uv_time = "2020-06-29T13:32:07.067Z", // uv_max = 12.1, // uv_max_time = "2020-06-29T16:32:07.067Z", // safe_exposure_time = new SafeExposureTimeDto // { // st1 = 10, // st2 = 20, // st3 = 30, // st4 = 40, // st5 = 50, // st6 = 60 // } // }, WeatherInfo = weatherData, Users = _mapper.Map <IEnumerable <UserDto> >(usersFromRepo), }; return(Ok(dashboardDto)); }
public DashboardDto GetStudentById(Guid id) { var dtos = new DashboardDto(); using (var context = new DataContext(ConnectionString)) { dashboardRepo = new Repository <DashboardModel>(context); var objs = dashboardRepo.Get(id); var mappedObject = Map(objs, dtos, typeof(List <DashboardModel>), typeof(List <DashboardDto>)); dtos = mappedObject as DashboardDto; } return(dtos); }
public Task <DashboardDto> GetDashboardInfo() { var dashboard = new DashboardDto(); dashboard.TotalNumOfProducts = _context.Products.Count(); dashboard.NumOfProductByUser = _context.Products.Count(x => x.CreatedBy == _currentUser.UserId); dashboard.ProductCategories = _context.Categories .Include(p => p.Products) .Select(c => new ProductCategories { Category = c.CategoryName, NumberOfProducts = c.Products.Count }) .ToList(); return(Task.FromResult(dashboard)); }
public async Task <IActionResult> DashboardRequest([FromBody] DashboardRequestDto req) { var clients = await unitOfWork.Client.GetMany(p => p.CreatedDate.Date.Year == req.Year).ToListAsync(); var policies = await unitOfWork.PoliciesMotor.GetMany(p => p.CreatedDate.Date.Year == req.Year).ToListAsync(); var ActiveQuotation = unitOfWork.ClientQuotation.GetMany(p => p.StatusId != (int)ClientQuotationStatusEnum.Purchased && p.CreatedDate.Date.Year == req.Year).Count(); var LatestActiveQuotations = await unitOfWork.ClientQuotation.GetlatestQuotation(req.Year); var expiringPolicies = await unitOfWork.PoliciesMotor.GetExpiredPoliciesInclude(req.Year); var PoliciesChart = await unitOfWork.PoliciesMotor.GetPoliciesChart(req.Year); var QuotitionRequestChart = await unitOfWork.PoliciesMotor.GetQuotitionRequestChart(req.Year); int pageSize = req.PageSize ?? configuration.GetValue <int>("PagingOptions:PageSize"); int pageNumber = req.PageNumber ?? configuration.GetValue <int>("PagingOptions:PageNumber"); DashboardDto data = new DashboardDto() { LatestActiveQuotations = mapper.Map <IEnumerable <ClientQuotationMotor>, IEnumerable <LatestActiveQuotationsDto> >(PagingList.Create(LatestActiveQuotations, pageSize, pageNumber)), PoliciesChart = PoliciesChart.ToList(), QuotitionRequestChart = QuotitionRequestChart.ToList(), TotalClients = clients.Count(), TotalPolicies = policies.Count(), ActiveQuotation = ActiveQuotation, ExpiringPolicies = expiringPolicies.Count() }; if (data == null) { return(NotFound(new BaseResponse(false, 404, "Previous request data was not found"))); } DashboardResponseDto response = new DashboardResponseDto() { Data = data, IsSuccess = true, StatusCode = (int)HttpStatusCode.OK, ResponseMessage = "Request has been complited successfully" }; return(Ok(response)); }
public IHttpActionResult UpdateDashboard(int id, DashboardDto dashboardDto) { if (!ModelState.IsValid) { return(BadRequest()); } var dashboardInDb = _context.Dashboards.SingleOrDefault(c => c.Id == id); if (dashboardInDb == null) { return(NotFound()); } Mapper.Map(dashboardDto, dashboardInDb); _context.SaveChanges(); return(Ok()); }