public ActionResult Join(JoinViewModel model)
        {
            var db = new Entities();
            Game game = db.Games.Single(g => g.ID == model.JoinInfo.GameID);

            if (game.HasStarted)
            {
                ModelState.AddModelError(string.Empty, "You cannot join this game, because it has already started.");
            }

            if (game.Password != null)
            {
                if (string.IsNullOrEmpty(model.JoinInfo.Password))
                    ModelState.AddModelError("JoinInfo.Password", "You must enter the password to join this game.");
                else if (!GameService.CheckPassword(model.JoinInfo.Password, game))
                    ModelState.AddModelError("JoinInfo.Password", "The password you entered is incorrect.");
            }

            if (!ModelState.IsValid)
                return View("Lobby", new LobbyViewModel(game, User.Identity.GetUserId(), model.JoinInfo));

            GameService.JoinGame(game, User.Identity.GetUserId(), model.JoinInfo.Name);

            if (game.GamePlayers.Count >= game.NumPlayers)
            {
                GameService.Start(db, game);
                db.SaveChanges();

                // TODO: send notification email?
            }
            else
                db.SaveChanges();

            return RedirectToAction("Play", new { id = game.ID });
        }
        public async Task JoinMethodAddMemberToMiniLegue()
        {
            var miniLegueList = new List <MiniLigue>()
            {
            };

            var miniLegueUsersList = new List <MiniLigueUser>();

            var miniLeagueRepo = new Mock <IDeletableEntityRepository <MiniLigue> >();

            miniLeagueRepo.Setup(x => x.All()).Returns(miniLegueList.AsQueryable());

            var miniUserRepo = new Mock <IDeletableEntityRepository <MiniLigueUser> >();

            miniUserRepo.Setup(x => x.AddAsync(It.IsAny <MiniLigueUser>())).Callback(
                (MiniLigueUser league) => miniLegueUsersList.Add(league));

            var service = new MiniLeaguesService(miniLeagueRepo.Object, miniUserRepo.Object);

            var model = new JoinViewModel
            {
                Id = "aaaaa",
            };

            await service.Join(model, "Milen");

            Assert.Equal(1, miniLegueUsersList.Count);
        }
        public async Task <IActionResult> Join(JoinViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new AccountUser
                {
                    Email       = model.Email,
                    UserName    = model.Email,  // Email로 로그인시키기 위해 UserName에 Email값을 넣고 Name 컬럼으로 이름값을 따로 저장
                    Name        = model.Name,
                    Gender      = model.Gender,
                    Address     = model.Address,
                    PhoneNumber = model.PhoneNumber
                };
                var result = await userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Login"));       // 회원 가입 성공시 로그인 페이지로 이동
                }

                ModelState.AddModelError("", "회원가입 실패");
            }

            return(View(model));     // 회원 가입 실패시
        }
Exemple #4
0
        public async Task <IActionResult> Join(JoinViewModel model)
        {
            if (ModelState.IsValid)
            {
                var currentUser = await _userManager.GetUserAsync(HttpContext.User);

                if (currentUser.HomeId != null)
                {
                    return(BadRequest());
                }

                var joinHome = _repository.GetHomeByNameAndPassword(model.Name, model.Password);

                if (joinHome == null)
                {
                    ModelState.AddModelError("ErrorMessage", "Invalid home login.");
                    return(BadRequest(ModelState));
                }

                joinHome.Users.Add(currentUser);
                currentUser.HomeId = joinHome.Id;

                await _repository.Commit();

                var mappedHome = _mapper.Map <Home, HomeStatusViewModel>(joinHome);

                return(Ok(mappedHome));
            }

            return(BadRequest(ModelState));
        }
        public ActionResult Join([Bind(Exclude = "USerId,Time,FreeSpace,TName")] JoinViewModel model, [Bind(Exclude = "Subscriptions,UserName,Password,FirstName,LastName,ConfirmPassword,BirthDate,PhoneNumber,IsEmailVerified,ActivationCode")] UserJoinViewModel umodel)
        {
            Treniruotes treniruotes = new Treniruotes()
            {
                Id          = model.Id,
                UsersString = model.UsersString,
                Joins       = model.Joins
            };

            Users user = new Users()
            {
                Id    = umodel.Id,
                Email = umodel.Email
            };

            if (ModelState.IsValid)
            {
                treniruotes.Joins++;
                treniruotes.UsersString = treniruotes.UsersString + umodel.Id.ToString() + ",";

                db.Entry(treniruotes).State = EntityState.Modified;
                db.SaveChanges();
            }


            return(View("Index"));
        }
        public IActionResult Join(JoinViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (!projectDataService.Exists(model.ProjectCode))
                {
                    ModelState.AddModelError("ProjectCode", "Project code is not valid");

                    return(View(model));
                }

                var employeeId = userManager.GetUserId(this.User);

                var serviceModel = new JoinServiceModel
                {
                    EmployeeId  = employeeId,
                    ProjectCode = model.ProjectCode
                };

                projectDataService.Join(serviceModel);

                return(View());
            }
            return(View(model));
        }
Exemple #7
0
        public async Task <IActionResult> Join(JoinViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            var userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (this.miniLiguesService.IsAMember(model.Id, userId))
            {
                var miniLigueName = this.miniLiguesService.MiniLigueName(model.Id);
                model.Name = miniLigueName;
                this.TempData["Message"] = "You are already a member of this League!";
                return(this.View(model));
            }
            else if (!this.miniLiguesService.IsCorrectPassword(model.Id, model.Password))
            {
                var miniLigueName = this.miniLiguesService.MiniLigueName(model.Id);
                model.Name = miniLigueName;
                this.TempData["Message"] = "Invalid Password!";
                return(this.View(model));
            }

            await this.miniLiguesService.Join(model, userId);

            return(this.Redirect("/MiniLigues/MyMiniLigues"));
        }
Exemple #8
0
        //protected Boolean TestMode = System.Configuration.ConfigurationManager.AppSettings["testMode"].Equals("N") ? false : true;
        public ActionResult Index()
        {
            // 取得 HomeViewModel 基本資料
            var           viewModel = GetHomeViewModel();
            JoinViewModel model     = new JoinViewModel
            {
                LogoInfoList = viewModel.LogoInfoList,
                ArticleItem  = viewModel.ArticleItem
            };

            // 取得參與募資資料
            string          caseType   = "3";
            string          caseStatus = "01";
            string          pageIndex  = "1";
            string          order      = "01";
            LoanCaseService service    = new LoanCaseService();

            model.LoanCaseList = service.GetLoanCaseList(new LoanCaseListDto
            {
                CASE_TYPE   = caseType,
                CASE_STATUS = caseStatus,
                PAGE_INDEX  = pageIndex,
                PAGE_NUM    = JoinViewModel.VIEW_COUNT_INTERVAL.ToString(),
                ORDER       = order
            });

            return(View(model));
        }
        public async Task <ActionResult> CraeteStudentData(JoinViewModel model, int department)
        {
            var Students = db.Students.ToList();

            if (ModelState.IsValid)
            {
                var user = new Student {
                    Name = model.Name, UserName = model.Name, Email = model.Email, Address = model.Address, BD = model.BirthDate, UserAccessType = "Student", IsActivated = true, GradeOfAbsence = 600, NoOfPermissions = 0, NoOfAbsenceDay = 0
                };
                var result = await userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    string code = await userManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    await userManager.SendEmailAsync(user.Id, "Student , Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    var RoleAssigner = userManager.AddToRole(user.Id, "Student");

                    TempData["Student"] = user;
                    return(RedirectToAction("StudentsList"));
                }
                AddErrors(result);
            }
            return(PartialView("StudentsList"));
        }
Exemple #10
0
        public ActionResult Join([Bind(Include = "Id,Password")] JoinViewModel viewModel)
        {
            ApplicationUser user = userRepository.GetUser(User.Identity.GetUserId());
            Game            game = gameRepository.GetGame(viewModel.Id);

            //sprawdzanie czy gracz nie ma juz zaczętych maksymalnej liczby gier
            if (userRepository.HaveMaxGames(user))
            {
                return(RedirectToAction("GameList", new { id = true }));
            }
            if (ModelState.IsValid)
            {
                if (game.Password != viewModel.Password)
                {
                    return(View(new JoinViewModel {
                        Id = viewModel.Id, Name = game.Name, WrongPassword = true
                    }));
                }
                if (game.Players.Contains(user) || game.IsBegan)
                {
                    return(RedirectToAction("GameList"));
                }
                gameRepository.AddUserToGame(user, game);
                return(RedirectToAction("GameList"));
            }
            return(View(new JoinViewModel {
                Id = viewModel.Id, Name = game.Name, WrongPassword = true
            }));
        }
Exemple #11
0
        public ActionResult Join(int id)
        {
            ApplicationUser user = userRepository.GetUser(User.Identity.GetUserId());
            Game            game = gameRepository.GetGame(id);

            //sprawdzanie czy gracz nie ma juz zaczętych maksymalnej liczby gier
            if (userRepository.HaveMaxGames(user))
            {
                return(RedirectToAction("GameList", new { id = true }));
            }
            //jeżeli gra ma hasło wyswietl strone do wprowadzania hasła
            if (game.HavePassword())
            {
                JoinViewModel viewModel = new JoinViewModel {
                    Id = id, Name = game.Name
                };
                return(View(viewModel));
            }
            if (game.Players.Contains(user) || game.IsBegan)
            {
                return(RedirectToAction("GameList"));
            }
            gameRepository.AddUserToGame(user, game);
            return(RedirectToAction("GameList"));
        }
Exemple #12
0
        public ActionResult LoadMoneyTable(int buy_cnt, string id)
        {
            JoinViewModel viewModel = new JoinViewModel();

            try
            {
                var calmodel = Session["Project_LoanCaseCalculate"] as LoanCaseCalculateResponseDto;

                LoanCaseCalculateResponseDto model = new LoanCaseCalculateResponseDto();
                model.CALUATLE_LIST = new List <CALUATLE_LIST>();

                decimal PRE_POWER_GEN         = 0;
                decimal PRE_POWER_FEE         = 0;
                decimal PRE_APPOR_RENT        = 0;
                decimal PRE_APPOR_INSURANCE   = 0;
                decimal PRE_OTHER_FEE         = 0;
                decimal PRE_ANNUAL_RECEIPT    = 0;
                decimal PRE_ACCUMLATE_RECEIPT = 0;

                foreach (var item in calmodel.CALUATLE_LIST)
                {
                    CALUATLE_LIST lists = new CALUATLE_LIST();
                    decimal.TryParse(item.PRE_POWER_GEN, out PRE_POWER_GEN);
                    decimal.TryParse(item.PRE_POWER_FEE, out PRE_POWER_FEE);
                    decimal.TryParse(item.PRE_APPOR_RENT, out PRE_APPOR_RENT);
                    decimal.TryParse(item.PRE_APPOR_INSURANCE, out PRE_APPOR_INSURANCE);
                    decimal.TryParse(item.PRE_OTHER_FEE, out PRE_OTHER_FEE);
                    decimal.TryParse(item.PRE_ANNUAL_RECEIPT, out PRE_ANNUAL_RECEIPT);
                    decimal.TryParse(item.PRE_ACCUMLATE_RECEIPT, out PRE_ACCUMLATE_RECEIPT);
                    PRE_POWER_GEN         *= buy_cnt;
                    PRE_POWER_FEE         *= buy_cnt;
                    PRE_APPOR_RENT        *= buy_cnt;
                    PRE_APPOR_INSURANCE   *= buy_cnt;
                    PRE_OTHER_FEE         *= buy_cnt;
                    PRE_ANNUAL_RECEIPT    *= buy_cnt;
                    PRE_ACCUMLATE_RECEIPT *= buy_cnt;

                    lists.YEAR = item.YEAR;
                    lists.PRE_POWER_PERFORMANCE = item.PRE_POWER_PERFORMANCE;
                    lists.PRE_POWER_GEN         = PRE_POWER_GEN.ToString();
                    lists.PRE_POWER_FEE         = PRE_POWER_FEE.ToString();
                    lists.PRE_APPOR_RENT        = PRE_APPOR_RENT.ToString();
                    lists.PRE_APPOR_INSURANCE   = PRE_APPOR_INSURANCE.ToString();
                    lists.PRE_OTHER_FEE         = PRE_OTHER_FEE.ToString();
                    lists.PRE_ANNUAL_RECEIPT    = PRE_ANNUAL_RECEIPT.ToString();
                    lists.PRE_ACCUMLATE_RECEIPT = PRE_ACCUMLATE_RECEIPT.ToString();

                    model.CALUATLE_LIST.Add(lists);
                }
                viewModel.LoanCaseCalculate = model;

                return(PartialView("_ProjectTabMoneyTable", viewModel));
            }
            catch (Exception ex)
            {
                TempData["errorMsg"] = "error";
                return(Json(new { errorcode = -1, ERRMSG = Url.Action("Error", "Home") }, JsonRequestBehavior.AllowGet));
            }
        }
        public async Task <ActionResult> Register(JoinViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user           = (ApplicationUser)null;
                var UserAccessType = Request.Form["item"];
                if (UserAccessType == "Student")
                {
                    user = new Student {
                        Name = model.Name, UserName = model.Name, Email = model.Email, Address = model.Address, BD = model.BirthDate, GradeOfAbsence = 600, NoOfAbsenceDay = 0, NoOfPermissions = 0, UserAccessType = "Student"
                    };
                    var result = await UserManager.CreateAsync(user, model.Password);

                    if (result.Succeeded)
                    {
                        await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);


                        string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                        var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                        await UserManager.SendEmailAsync(user.Id, "Student , Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                        var RoleAssigner = UserManager.AddToRole(user.Id, "Student");

                        TempData["Student"] = user;
                        return(RedirectToAction("Index", "Home"));
                    }
                    AddErrors(result);
                }
                else if (UserAccessType == "Instructor")
                {
                    user = new Instructors {
                        Name = model.Name, UserName = model.Name, Email = model.Email, Address = model.Address, BD = model.BirthDate, UserAccessType = "Instructor"
                    };
                    var result = await UserManager.CreateAsync(user, model.Password);

                    if (result.Succeeded)
                    {
                        await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);


                        string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                        var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                        await UserManager.SendEmailAsync(user.Id, "Instructor , Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                        var RoleAssigner = UserManager.AddToRole(user.Id, "Instructor");
                        TempData["Instructor"] = user;
                        return(RedirectToAction("Index", "Home"));
                    }
                    AddErrors(result);
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemple #14
0
        public IActionResult GrabJoins()
        {
            JoinViewModel joinModel = new JoinViewModel {
                FullSetBosses = _db.FullSetBosses.ToArray(),
                FullSetGears  = _db.FullSetGears.ToArray()
            };

            return(Json(joinModel));
        }
        public ConfirmMinistryView(Ministerio ministerio)
        {
            InitializeComponent();
            viewmodel            = new JoinViewModel();
            viewmodel.Ministerio = ministerio;
            BindingContext       = viewmodel;

            Api = new ApiServices();
        }
        public ConfirmMeetingView(Reuniao reuniao)
        {
            InitializeComponent();
            viewmodel         = new JoinViewModel();
            viewmodel.Reuniao = reuniao;
            BindingContext    = viewmodel;

            Api = new ApiServices();
        }
Exemple #17
0
        public IActionResult Join(int id)
        {
            var person = new JoinViewModel()
            {
                ID = id
            };

            return(View(person));
        }
Exemple #18
0
        public IActionResult JoinRoom(string roomUid)
        {
            var vm = new JoinViewModel
            {
                RoomUid = roomUid
            };

            return(View(vm));
        }
Exemple #19
0
        public ActionResult Project(string id = "")
        {
            JoinViewModel model = new JoinViewModel();

            try
            {
                model.LoanCaseIntroduct = service.GetLoanCaseIntroList(new LoanCaseIntroductDto()
                {
                    CASE_TYPE = "3", CASE_NO = id
                });
                model.LoanCaseSchedule = service.GetProjectSchedule(new LoanCaseScheduleDtlDto()
                {
                    CASE_TYPE = "3", CASE_NO = id
                });
                model.LoanCaseCalculate = service.GetProjectCalculate(new LoanCaseCalculateDto()
                {
                    CASE_NO = id
                });
                Session["Project_LoanCaseCalculate"] = model.LoanCaseCalculate;
            }
            catch (Exception ex)
            {
                TempData["errorMsg"] = ex.Message.Substring(0, ex.Message.IndexOf("statusCode"));
                return(RedirectToAction("Error", "Home"));
            }

            if (model.UserInfoDetail == null)
            {
                UserInfoDto user = new UserInfoDto()
                {
                    MBR_LVL = "00", VAR_RETURN_NOTE = ""
                };
                model.UserInfoDetail = user;
            }

            #region 專案附件
            LoanCaseAttachResponseDto attach = new LoanCaseAttachResponseDto();
            try
            {
                attach = service.LoanCaseAttach(new LoanCaseAttachDto()
                {
                    CASE_TYPE = "3", CASE_NO = id
                });
            }
            catch (Exception ex)
            {
                TempData["errorMsg"] = ex.Message.Substring(0, ex.Message.IndexOf("statusCode"));
                return(RedirectToAction("Error", "Home"));
            }

            model.LoanCaseFile = attach;
            #endregion

            return(View(model));
        }
Exemple #20
0
        public IActionResult Join(string id)
        {
            var miniLigueName = this.miniLiguesService.MiniLigueName(id);
            var model         = new JoinViewModel
            {
                Id   = id,
                Name = miniLigueName,
            };

            return(this.View(model));
        }
        public JoinView()
        {
            InitializeComponent();
            JoinViewModel vm = new JoinViewModel();

            this.DataContext = vm;
            if (vm.CloseAction == null)
            {
                vm.CloseAction = new Action(this.Close);
            }
        }
Exemple #22
0
        /// <summary>
        /// Open dialog to choose a single datasource and join it.
        /// </summary>
        public static bool AddJoin(IAppContext context, IAttributeTable table)
        {
            var model = new JoinViewModel(table);

            if (context.Container.Run <JoinTablePresenter, JoinViewModel>(model))
            {
                return(true);
            }

            return(false);
        }
        public async Task <HttpResponseMessage> Join([FromBody] JoinViewModel join)
        {
            Player newPlayer = new Player(join.Name);

            newPlayer.SetRole(join.Role);
            var result = _mastermindMultiplayerAppService.Join(newPlayer, join.RoomId);

            return(await Task <HttpResponseMessage> .Factory.StartNew(() =>
            {
                return Request.CreateResponse(HttpStatusCode.OK, new { Gamekey = result.Gamekey, RoomdId = result.RoomId, Message = result.Message });
            }));
        }
        public async Task Join(JoinViewModel model, string userId)
        {
            var memberToMiniLigue = new MiniLigueUser
            {
                MiniLigueId = model.Id,
                UserId      = userId,
            };

            await this.miniLigueUserRepository.AddAsync(memberToMiniLigue);

            await this.miniLigueUserRepository.SaveChangesAsync();
        }
Exemple #25
0
        public ActionResult Index()
        {
            JoinViewModel model = new JoinViewModel();

            if (model.UserInfoDetail == null)
            {
                UserInfoDto user = new UserInfoDto()
                {
                    MBR_LVL = "", VAR_RETURN_NOTE = ""
                };
                model.UserInfoDetail = user;
            }

            return(View(model));
        }
        public MainWindowViewModel()
        {
            Title                = $"{AppInfo.ProductName} v{AppInfo.DisplayVersion}";
            JoinViewModel        = new JoinViewModel();
            SplitViewModel       = new SplitViewModel();
            HashViewModel        = new HashViewModel();
            AppSettingsViewModel = new AppSettingsViewModel();

            // All tools tab except settings
            _toolsTab = new TabViewModelBase[] { JoinViewModel, SplitViewModel, HashViewModel };

            var tabToSelect = _toolsTab.FirstOrDefault(tab => string.Equals(tab.TabId, Settings.Default.ActiveTabId, StringComparison.OrdinalIgnoreCase));

            SelectedTab = tabToSelect ?? _toolsTab[0];
        }
Exemple #27
0
        public ActionResult Join()
        {
            IQueryable <Game> results;

            using (var session = documentStore.OpenSession())
            {
                results = session.Query <Game>().Where(x => x.CanJoin);
            }

            JoinViewModel vm = new JoinViewModel
            {
                Games = results.ToList()
            };

            return(View(vm));
        }
Exemple #28
0
        public async Task <IActionResult> Index(JoinViewModel model)
        {
            var currentSeason = await _dataService.GetCurrentSeasonId();

            if (ModelState.IsValid && !String.IsNullOrEmpty(model.JoinCode))
            {
                model.JoinCode = model.JoinCode.ToUpper();

                var school = await _context.School.FirstOrDefaultAsync(s =>
                                                                       s.SeasonId == currentSeason && s.JoinCode.Equals(model.JoinCode));

                if (school is not null)
                {
                    var appUser = await _userManager.GetUserAsync(User);

                    appUser.SchoolId = school.SchoolId;

                    var identity   = (User.Identity as ClaimsIdentity);
                    var guestClaim = identity.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Role && c.Value == "Guest");
                    if (guestClaim != null)
                    {
                        identity.RemoveClaim(guestClaim);
                    }
                    identity.AddClaim(new Claim(ClaimTypes.Role, "Player"));

                    // reset user roles
                    var roles = await _userManager.GetRolesAsync(appUser);

                    await _userManager.RemoveFromRolesAsync(appUser, roles);

                    // assign new role
                    await _userManager.AddToRoleAsync(appUser, "Player");

                    await _signInManager.SignInAsync(appUser, true);

                    await _dataService.SyncExternalPlayer(appUser.Id);

                    return(RedirectToAction(nameof(Index)));
                }

                return(RedirectToAction(nameof(Index), new { err = 1 }));
            }

            return(RedirectToAction(nameof(Index)));
        }
Exemple #29
0
        public ActionResult ProjectList(int status, int page, string orderType)
        {
            try
            {
                JoinViewModel model       = new JoinViewModel();
                string        case_status = "01";
                string        view_name   = "";
                if (page < 0)
                {
                    page = 0;
                }
                // 1 : 募資中 2 : 發電中
                switch (status)
                {
                case 1: case_status = "01"; view_name = "_IndexProjectContent"; break;

                case 2: case_status = "02"; view_name = "_OnlineProjectContent"; break;

                default: return(PartialView());    // status亂傳直接回空response
                }

                model.LoanCaseList = service.GetLoanCaseList(new LoanCaseListDto()
                {
                    CASE_TYPE = "3", CASE_STATUS = case_status, PAGE_INDEX = page.ToString(), PAGE_NUM = JoinViewModel.VIEW_COUNT_INTERVAL.ToString(), ORDER = orderType
                });

                #region view more隱藏(使用API的方法)
                //int next_idx = page * JoinViewModel.VIEW_COUNT_INTERVAL + 1;
                //if (service.GetLoanCaseList(new LoanCaseListDto() { CASE_TYPE = "3", CASE_STATUS = case_status, PAGE_INDEX = next_idx.ToString(), PAGE_NUM = "1", ORDER = orderType }).Data.Count() <= 0)
                //model.End_Flag = true;
                #endregion

                if (model.LoanCaseList.Data == null || model.LoanCaseList.Data.Count() <= 0)
                {
                    model.End_Flag = true;
                }
                // view_name -> 募資中 : "_IndexProjectContent" ; 發電中 : "_OnlineProjectContent"
                return(PartialView(view_name, model));
            }
            catch (Exception ex) {
                TempData["errorMsg"] = "專案列表載入失敗:請稍後再試或聯絡客服。";
                return(Json(new { errorcode = -1, ERRMSG = Url.Action("Error", "Home") }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Join(int id)
        {
            int uid = HttpContext.Session.GetInt32("userId").Value;

            var r = _context.ClassStudents.Select(x => x).Where(x => x.ClassId == id && x.StudentId == uid).FirstOrDefault();

            ClassStudents classStudents = new ClassStudents
            {
                ClassId   = id,
                StudentId = uid
            };

            if (r == null)
            {
                _context.ClassStudents.Add(classStudents);
                _context.SaveChanges();
            }
            ViewBag.classId = id;
            var classname = _context.Class.Select(x => x).Where(x => x.Id == id).FirstOrDefault().Name;

            HttpContext.Session.SetString("ClassName", classname);
            HttpContext.Session.SetInt32("classid", id);
            var messages = from x in _context.Chat
                           where x.ClassId == id
                           select x;

            var files = from x in _context.FileStorage
                        where x.ClassId == id
                        select x;

            var cid = from x in _context.Class
                      where x.Id == id
                      select x.CreatorId;

            JoinViewModel joinViewModel = new JoinViewModel
            {
                Chats        = messages.ToList(),
                FileStorages = files.ToList()
                ,
                CreatorId = cid.FirstOrDefault().HasValue ? cid.FirstOrDefault().Value : 0
            };

            return(View(joinViewModel));
        }
Exemple #31
0
        public ActionResult Join(int GroupId, string UserId, string Message)
        {
            var userJoined = _context.GroupUsers.Where(g => (g.groupId == GroupId && g.applicationUserId.Equals(UserId))).SingleOrDefault();

            if (userJoined != null)
            {
                return(RedirectToAction("Group", new RouteValueDictionary(
                                            new { controller = "Groups", action = "Group", id = GroupId })));
            }

            JoinViewModel viewmodel = new JoinViewModel
            {
                groupId = GroupId,
                userId  = UserId,
                message = Message
            };

            return(View(viewmodel));
        }