Beispiel #1
0
        public async Task <IActionResult> Register(UserDto userDto)
        {
            if (userDto == null)
            {
                return(NoContent());
            }
            if (_baseEduContext.UserInfo.Where(x => x.UserName == userDto.UserName).Count() > 0)
            {
                return(NotFound());
            }
            Edu.Entity.MySqlEntity.UserInfo userInfo = new Edu.Entity.MySqlEntity.UserInfo()
            {
                UserName = userDto.UserName,
                Pwd      = MD5Helper.GetMD5String(userDto.Password),
                Guid     = Guid.NewGuid().ToString(),
                States   = 1
            };
            await _baseEduContext.UserInfo.AddAsync(userInfo);

            if (await _baseEduContext.SaveChangesAsync() > 0)
            {
                var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);
                identity.AddClaim(new Claim(ClaimTypes.Sid, userInfo.Id.ToString()));
                identity.AddClaim(new Claim(ClaimTypes.Name, userInfo.UserName));

                var timespanExpiry = new TimeSpan(0, 0, 30, 0, 0);
                //identity.AddClaim(new Claim(ClaimTypes.Role, userInfo.Photo));
                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity));

                return(RedirectToAction("Index", "Home"));
            }
            return(Ok());
        }
Beispiel #2
0
        public async Task <IActionResult> Create(Meet meet)
        {
            try
            {
                // TODO: Add insert logic here
                await _baseEduContext.Meet.AddAsync(meet);

                if (await _baseEduContext.SaveChangesAsync() > 0)
                {
                    return(RedirectToAction(nameof(Index)));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #3
0
        public async Task <IActionResult> CreateRoom(Int64 roomID, Int32 meetID)
        {
            Room room = new Room();

            room.CreateDateTime = DateTime.Now;
            room.Numeric        = roomID;
            room.MeetID         = meetID;
            await _baseEduContext.Room.AddAsync(room);

            if (await _baseEduContext.SaveChangesAsync() > 0)
            {
                return(Content(""));
            }
            return(Content(""));
        }