// GET: Reports public ActionResult Index() { var MyId = User.Identity.GetUserId(); // 日報のリストから、表示用のビューモデルのリストを作成 List <ReportsIndexViewModel> indexViewModels = new List <ReportsIndexViewModel>(); //ReportsDBを更新日時が降順でreportsリストに格納 var reports = db.Reports .OrderByDescending(r => r.UpdatedAt) //.OrderByDescending(r => r.ReportDate) .ToList(); //LikesDBからいいねしている日報を抽出 var likes = db.Likes .Where(l => l.EmployeeId == MyId) .Select(l => l.ReportId) .ToList(); //1件ずつあるだけ回す foreach (Report report in reports) { ReportsIndexViewModel indexViewModel = new ReportsIndexViewModel { Id = report.Id, //Follow機能の為EmployeeIdを設定 EmployeeId = report.EmployeeId, // 従業員のリストからこの日報のEmployeeIdで検索をかけて取得した従業員の名前を設定 EmployeeName = db.Users.Find(report.EmployeeId).EmployeeName, ReportDate = report.ReportDate, CliantCompany = report.CliantCompany, Title = report.Title, Content = report.Content, }; //いいねしていた場合 if (likes.Contains(report.Id)) { //済みフラグ indexViewModel.LikeFlg = LikeStatus.Like; } else { //まだフラグ indexViewModel.LikeFlg = LikeStatus.UnLike; } //承認フラグ判定 if (report.Accepting == 0) { indexViewModel.AcceptFlg = AcceptStatus.UnAuthorize; } else { indexViewModel.AcceptFlg = AcceptStatus.Auhorized; } //ModelをModelsに追加 indexViewModels.Add(indexViewModel); } //Modelsをリターン return(View(indexViewModels)); }
public ActionResult Index() { string UserId = User.Identity.GetUserId(); //自分の日報だけのリストを作る。 var myReports = db.Reports .Where(r => r.EmployeeId == UserId) .OrderByDescending(r => r.ReportDate) .ToList(); //自分の日報リストから表示用のModelデータ(ReportIndexViewModel)のリストを作成 List <ReportsIndexViewModel> indexViewModels = new List <ReportsIndexViewModel>(); foreach (var report in myReports) { ReportsIndexViewModel indexViewModel = new ReportsIndexViewModel { Id = report.Id, EmployeeName = db.Users.Find(report.EmployeeId).EmployeeName, ReportDate = report.ReportDate, CliantCompany = report.CliantCompany, Title = report.Title, Content = report.Content }; indexViewModels.Add(indexViewModel); } return(View(indexViewModels)); }
// GET: Reports public ActionResult Index() { //ログインユーザーID取得 string UserId = User.Identity.GetUserId(); //フォロー先ユーザーList作成 List <string> myFollows = db.Follows .Where(r => r.EmployeeId == UserId) .Select(r => r.FollowId) .ToList(); // 日報のリストから、表示用のビューモデルのリストを作成 List <ReportsIndexViewModel> indexViewModels = new List <ReportsIndexViewModel>(); var reports = db.Reports.OrderByDescending(r => r.ReportDate).ToList(); foreach (Report report in reports) { ReportsIndexViewModel indexViewModel = new ReportsIndexViewModel { Id = report.Id, EmployeeName = db.Users.Find(report.EmployeeId).EmployeeName, EmployeeId = report.EmployeeId, ReportDate = report.ReportDate, Title = report.Title, Content = report.Content, NegotiationStatus = report.NegotiationStatus, }; indexViewModel.ApprovalStatus = report.ApprovalStatus == 1 ? "承認済み" : "未承認"; List <string> reactions = db.Reactions .Where(r => r.ReportId == report.Id) .Select(r => r.EmployeeId) .ToList(); indexViewModel.ReactionQuantity = reactions.Count(); //フォローボタン制御 if (report.EmployeeId == UserId) //ログインユーザー自身 { indexViewModel.FollowStatusFlag = FollowStatusEnum.LoginUser; } else if (myFollows.Contains(report.EmployeeId)) //フォロー済み { indexViewModel.FollowStatusFlag = FollowStatusEnum.Following; } else //未フォロー { indexViewModel.FollowStatusFlag = FollowStatusEnum.Unfollowed; } indexViewModels.Add(indexViewModel); } return(View(indexViewModels)); }
public IActionResult Index(ReportsIndexViewModel model) { List <Car> selected = new List <Car>(); foreach (var item in model.CheckboxItems) { if (item.Selected && item.Entity == "car") { selected.Add(_carsRepository.GetCar(item.Id)); } } return(RedirectToAction("index")); }
// GET: Reports public ActionResult Index() { string[] reports = new string[] { "AgentReport", "SkillReport" }; ReportsIndexViewModel reportsIndexViewModel = new ReportsIndexViewModel { ReportNames = new SelectList(reports), Report = new Report { Name = "SkillReport", DateFrom = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "T" + DateTime.Now.AddDays(-1).ToString("HH:mm"), DateTo = DateTime.Now.ToString("yyyy-MM-dd") + "T" + DateTime.Now.ToString("HH:mm") } }; return(View(reportsIndexViewModel)); }
public IActionResult Index() { var doctors = db.TblDoctor .Select(d => new DoctorViewModel { DoctorId = d.IntDoctorId, DoctorName = d.TxtDoctorName }) .ToList(); var viewModel = new ReportsIndexViewModel { Doctors = doctors }; return(View(viewModel)); }
// GET: Reports/ public async Task <IActionResult> Index() { var currentUser = await _userInfoManager.FindUser(User); var infectionReport = await _userInfoManager.GetOpenInfectionReport(currentUser); var DiagnosisDate = infectionReport?.DiagnosisDate; ReportsIndexViewModel model = new ReportsIndexViewModel { UserAtRisk = currentUser.AtRisk, UserInfected = currentUser.Infected, DiagnosisDate = DiagnosisDate }; return(View(model)); }
public ActionResult Index() { //ログインしている人のID取得 string UserId = User.Identity.GetUserId(); //フォロー先従業員IDリスト(myFollows)作成 List <string> myFollows = db.Follows .Where(f => f.EmployeeId == UserId) .Select(f => f.FollowId) .ToList(); //myFollowsに自分のID追加 myFollows.Add(UserId); //フォローしている日報取得 日付順に並べ替え List <Report> myReports = db.Reports .Where(r => myFollows.Contains(r.EmployeeId)) .OrderByDescending(r => r.ReportDate) .ToList(); //日報表示 List <ReportsIndexViewModel> indexViewModels = new List <ReportsIndexViewModel>(); foreach (Report report in myReports) { ReportsIndexViewModel indexViewModel = new ReportsIndexViewModel { Id = report.Id, EmployeeName = db.Users.Find(report.EmployeeId).EmployeeName, ReportDate = report.ReportDate, Title = report.Title, Content = report.Content, NegotiationStatus = report.NegotiationStatus }; indexViewModel.ApprovalStatus = report.ApprovalStatus == 1 ? "承認済み" : "未承認"; List <string> reactions = db.Reactions .Where(r => r.ReportId == report.Id) .Select(r => r.EmployeeId) .ToList(); indexViewModel.ReactionQuantity = reactions.Count(); indexViewModels.Add(indexViewModel); } return(View(indexViewModels)); }
// GET: Reactions public ActionResult Index() { //ログインユーザーID取得 string UserId = User.Identity.GetUserId(); //リアクション先日報IDList作成 List <int> myReportIds = db.Reactions .Where(r => r.EmployeeId == UserId) .Select(r => r.ReportId) .ToList(); // 日報のリストから、表示用のビューモデルのリストを作成 List <ReportsIndexViewModel> indexViewModels = new List <ReportsIndexViewModel>(); foreach (int reportId in myReportIds) { Report report = db.Reports.Find(reportId); ReportsIndexViewModel indexViewModel = new ReportsIndexViewModel { Id = report.Id, EmployeeName = db.Users.Find(report.EmployeeId).EmployeeName, EmployeeId = report.EmployeeId, ReportDate = report.ReportDate, Title = report.Title, Content = report.Content, NegotiationStatus = report.NegotiationStatus, }; indexViewModel.ApprovalStatus = report.ApprovalStatus == 1 ? "承認済み" : "未承認"; List <string> reactions = db.Reactions .Where(r => r.ReportId == reportId) .Select(r => r.EmployeeId) .ToList(); indexViewModel.ReactionQuantity = reactions.Count(); indexViewModels.Add(indexViewModel); } return(View(indexViewModels)); }
public IActionResult Index() { List <CheckboxItem> items = new List <CheckboxItem>(); foreach (var item in _carsRepository.GetAllCars()) { CheckboxItem ent = new CheckboxItem { Id = item.Id, Name = item.RegistrationNumber, Entity = "car", Selected = false }; items.Add(ent); } ReportsIndexViewModel model = new ReportsIndexViewModel { CheckboxItems = items }; return(View(model)); }
// GET: Reports public ActionResult Index() { // 日報のリストから、表示用のビューモデルのリストを作成 List <ReportsIndexViewModel> indexViewModels = new List <ReportsIndexViewModel>(); var reports = db.Reports .OrderByDescending(r => r.ReportDate) .ToList(); foreach (Report report in reports) { ReportsIndexViewModel indexViewModel = new ReportsIndexViewModel { Id = report.Id, // 従業員のリストからこの日報のEmployeeIdで検索をかけて取得した従業員の名前を設定 EmployeeName = db.Users.Find(report.EmployeeId).EmployeeName, ReportDate = report.ReportDate, Title = report.Title, Content = report.Content }; indexViewModels.Add(indexViewModel); } return(View(indexViewModels)); }