Пример #1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            var appUser = await AppUsers.Get(User);

            if (id is not null)
            {
                var record = await DataContext.HomeReviewFeatureChoices
                             .Include(o => o.HomeFeatureChoices)
                             .Include(o => o.UserWeights)
                             .FirstOrDefaultAsync(r => r.Id == id);

                if (record is null)
                {
                    return(NotFound());
                }

                record.UserWeights.Clear();
                await DataContext.SaveChangesAsync();

                record.HomeFeatureChoices.Clear();
                await DataContext.SaveChangesAsync();

                DataContext.Remove(record);
                await DataContext.SaveChangesAsync();
            }

            return(RedirectToPage("./EditFeature", new { Id = FeatureId }));
        }
Пример #2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            var appUser = await AppUsers.Get(User);

            if (id is not null)
            {
                Link = await DataContext.HomeReviewLinks
                       .Include(r => r.Home)
                       .FirstOrDefaultAsync(r => r.Id == id);
            }

            if (Link is null)
            {
                return(NotFound());
            }

            Link.Home.ModifiedById = appUser.Id;
            Link.Home.Modified     = DateTime.Now;

            DataContext.Entry(Link.Home).State = EntityState.Modified;
            DataContext.HomeReviewLinks.Remove(Link);

            await DataContext.SaveChangesAsync();

            return(RedirectToPage("./HomeDetails", new { Id = Link.HomeId }));
        }
 public IActionResult OnGet(int id)
 {
     CurrentUser = _users.Get(id);
     if (CurrentUser is null)
     {
         return(NotFound());
     }
     return(Page());
 }
Пример #4
0
        private LoginResult Parse(PassportLoginRequest model)
        {
            //过滤字段无效字符
            model.Trim();

            var result = new LoginResult();

            //获取应用信息
            var appInfo = _appInfoService.Get(model.AppKey);

            if (appInfo == null)
            {
                result.Success  = false;
                result.ErrorMsg = "应用不存在";
            }
            TempData[AppInfo] = appInfo;

            //获取用户信息
            var userInfo = _appUserService.Get(model.UserName);

            if (userInfo == null)
            {
                result.Success  = false;
                result.ErrorMsg = "用户不存在";
            }

            //if (userInfo.UserPwd != model.Password.ToMd5())
            //{
            //    //密码不正确
            //    return View(model);
            //}

            var currentSession = new UserAuthSession
            {
                UserName    = model.UserName,
                Token       = Guid.NewGuid().ToString().ToMd5(),
                InvalidTime = DateTime.Now.AddMinutes(10),
                AppKey      = model.AppKey,
                CreateTime  = DateTime.Now,
                IpAddress   = Request.UserHostAddress
            };

            //创建Session
            new UserAuthSessionService().Create(currentSession);

            result.Success   = true;
            result.ReturnUrl = appInfo.ReturnUrl;
            result.Token     = currentSession.Token;
            return(result);
        }
Пример #5
0
        public TransactionResult <AppUser> GetAppUser(int id)
        {
            TransactionResult <AppUser> result = new TransactionResult <AppUser>();
            var serviceResult = service.Get(id);

            if (serviceResult.ActionResult & serviceResult.HavingData)
            {
                result.Data = serviceResult.Data;
            }
            else
            {
                result.Code    = 103;
                result.Message = "暂无数据";
            }
            return(result);
        }
Пример #6
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var appUser = await AppUsers.Get(User);

            var homeRecord = await DataContext.HomeReviewHomes.FindAsync(Home.Id);

            if (homeRecord is null)
            {
                return(NotFound());
            }

            var linkRecord = await DataContext.HomeReviewLinks.FirstOrDefaultAsync(r => r.Link == Address);

            if (linkRecord is null)
            {
                linkRecord = new Data.Models.HomeReviewLink {
                    Link         = Address,
                    HomeId       = homeRecord.Id,
                    CreatedById  = appUser.Id,
                    Created      = DateTime.Now,
                    ModifiedById = appUser.Id,
                    Modified     = DateTime.Now
                };

                DataContext.HomeReviewLinks.Add(linkRecord);

                homeRecord.ModifiedById = appUser.Id;
                homeRecord.Modified     = DateTime.Now;

                DataContext.Entry(homeRecord).State = EntityState.Modified;

                await DataContext.SaveChangesAsync();
            }

            return(RedirectToPage("./HomeDetails", new { Home.Id }));
        }
Пример #7
0
 public async Task <ActionResult <List <AppUser> > > Get()
 {
     return(await _appUserService.Get());
 }