Exemplo n.º 1
0
        public AppDTO LoginUser(Login model)
        {
            var response = new AppDTO();
            var login    = db.Users.FirstOrDefault(x => x.Email_Id == model.UserId && x.Password == model.Password);

            if (login != null)
            {
                response = new AppDTO()
                {
                    IsLoggedIn = true,
                    User_Id    = login.User_Id,
                    ErrotMsg   = "none"
                };
            }
            else
            {
                response = new AppDTO()
                {
                    IsLoggedIn = false,
                    User_Id    = "none",
                    ErrotMsg   = "Email Id or password is wrong"
                };
            }
            return(response);
        }
Exemplo n.º 2
0
        public async Task <AppDTO> SaveApp(AppDTO app)
        {
            var entity = _db.AppRepository.FindOne(x => x.Id == app.Id);

            if (!Uri.IsWellFormedUriString(app.URL, UriKind.RelativeOrAbsolute))
            {
                throw new InvalidOperationException("URL is not well formatted");
            }
            if (entity != null)
            {
                _db.AppRepository.Update(app, entity);
            }
            else
            {
                app.UserId = UserId;
                entity     = Map <Domain.App>(app);
                _db.AppRepository.Add(entity);
            }

            await _db.SaveChangesAsync();

            RecurringJob.AddOrUpdate(entity.Id.ToString(), () => CheckApp(entity.Id), entity.Interval);


            return(app);
        }
Exemplo n.º 3
0
        public AppDTO PutAppDTO(int id, AppDTO dto)
        {
            App a = Get(id).Result.Value;

            AppDTO.DtoToApp(dto, a);
            return(AppDTO.AppToDto(Put(id, a).Result.Value));
        }
Exemplo n.º 4
0
        public ActionResult Query(AppDTO param, PageParam pageParam)
        {
            List <AppDTO> list = new List <AppDTO>();

            _typeAdapter.Adapt(_appService.Query(param, pageParam).ToList(), list);
            return(Json(new { total = pageParam.TotalRecordCount, rows = list }));
        }
Exemplo n.º 5
0
        public IActionResult RadioButtonAction()
        {
            AppDTO model = new AppDTO()
            {
                Role = 2
            };
            List <RoleEum> roles = new List <RoleEum>()
            {
                new RoleEum()
                {
                    Id = 1, RoleName = "R1"
                },
                new RoleEum()
                {
                    Id = 2, RoleName = "R2"
                },
                new RoleEum()
                {
                    Id = 3, RoleName = "R3"
                }
            };

            ViewBag.Roles = roles;
            return(View(model));
        }
Exemplo n.º 6
0
        public AppDTO RegisterUser(Register model)
        {
            var response = new AppDTO();

            db.Users.Add(model);

            return(response);
        }
Exemplo n.º 7
0
        public IActionResult Get(int id)
        {
            var appDto = new AppDTO {
                Id = 1, Title = "test", IsCheck = true
            };

            return(Ok(new { app = appDto, is_success = true }));
        }
Exemplo n.º 8
0
        public List <AppDTO> GetAppDTO()
        {
            var           a = Get().Result.Value.ToList();
            List <AppDTO> b = new List <AppDTO>();

            a.ForEach(item => b.Add(AppDTO.AppToDto(item)));
            return(b);
        }
Exemplo n.º 9
0
        public async Task <AppDTO> PostAppDTO(AppDTO dto)
        {
            App app = new App();

            AppDTO.DtoToApp(dto, app);
            await Post(app);

            dto.Id = app.Id;
            return(dto);
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("Name,Interval,UserId,URL,Id")] AppDTO app)
        {
            if (ModelState.IsValid)
            {
                await _appService.SaveApp(app);

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

            return(View(app));
        }
Exemplo n.º 11
0
        public async Task Update([FromBody] AppDTO input)
        {
            var app = await pcontext.App.FirstOrDefaultAsync(u => u.Code == input.Code);

            if (app == null)
            {
                throw new Exception("系统信息不存在");
            }
            app.Name = input.Name;
            await pcontext.SaveChangesAsync();
        }
Exemplo n.º 12
0
 public async Task Create([FromBody] AppDTO input)
 {
     if (await pcontext.App.AnyAsync(u => u.Code == input.Code))
     {
         throw new Exception("已有相同系统编号存在");
     }
     pcontext.App.Add(new AppEntity
     {
         Code = input.Code,
         Name = input.Name
     });
     await pcontext.SaveChangesAsync();
 }
Exemplo n.º 13
0
        public IEnumerable <App> Query(AppDTO app, IPageParam pageParam)
        {
            var expression = ExpressionBuilder.True <App>();

            if (app != null)
            {
                expression = expression.AndIf(t => t.Name == app.Name, !string.IsNullOrEmpty(app.Name));
                expression = expression.AndIf(t => t.ClientID == app.ClientID, app.ClientID != 0);
            }
            if (pageParam == null)
            {
                return(_appRepo.Query(expression));
            }
            return(_appRepo.Query(expression, t => t.CreatedOn, true, pageParam));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Interval,UserId,URL,Id")] AppDTO app)
        {
            if (id != app.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await _appService.SaveApp(app);

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

            return(View(app));
        }
Exemplo n.º 15
0
        //Returns list of all Apps from Applist db as Json
        public JsonResult GetAllApps()
        {
            //Logic working before Super Admins
            //List<AppDTO> items = _appServiceAppList.GetAllApps().Select(x => new AppDTO
            //{
            //    id = x.Id,
            //    Text = x.Name
            //}).ToList();
            //return Json(new { items }, JsonRequestBehavior.AllowGet);

            List <AppDTO> items = new List <AppDTO>();

            var isAdmin = _userRoleService.IsSuperAdmin(User.Identity.Name);

            if (isAdmin)
            {
                var appList = _appServiceAppList.GetAllApps();

                foreach (var app in appList)
                {
                    var appDto = new AppDTO
                    {
                        id   = app.Id,
                        Text = app.Name
                    };
                    items.Add(appDto);
                }
            }
            else
            {
                var appList = _appServiceAppList.GrabAdminUserApps(User.Identity.Name);

                foreach (var app in appList)
                {
                    var appDto = new AppDTO
                    {
                        id   = app.Id,
                        Text = app.Name
                    };
                    items.Add(appDto);
                }
            }

            return(Json(new { items }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 16
0
        public void Update(AppDTO appParam)
        {
            Guard.ArgumentNotNull(appParam, "appParam");
            App oldApp = _appRepo.Get(u => u.ID == appParam.ID);

            if (oldApp == null)
            {
                throw new BusinessException("不存在该应用。");
            }
            oldApp.Name         = appParam.Name;
            oldApp.ClientSecret = appParam.ClientSecret;
            oldApp.ReturnUrl    = appParam.ReturnUrl;
            oldApp.IsCredible   = appParam.IsCredible;
            oldApp.IconUrl      = appParam.IconUrl;
            oldApp.InitUpdate(_currentContext.User?.Name);
            _appRepo.Update(oldApp);
            _unitOfWork.Commit();
        }
Exemplo n.º 17
0
        public void Add(AppDTO appParam)
        {
            Guard.ArgumentNotNull(appParam, "appParam");
            if (_appRepo.Exists(u => u.Name == appParam.Name))
            {
                throw new BusinessException("该应用已存在,请另外选择一个。");
            }
            App app = new App
            {
                Name         = appParam.Name,
                ClientSecret = appParam.ClientSecret,
                ReturnUrl    = appParam.ReturnUrl,
                IsCredible   = appParam.IsCredible,
                IconUrl      = appParam.IconUrl
            };

            app.Init(_currentContext.User?.Name);
            _appRepo.Add(app);
            _unitOfWork.Commit();
        }
        public IActionResult Login(LoginModel ul)
        {
            if (ModelState.IsValid)
            {
                HttpContext.Session.Clear();
                try
                {
                    HttpResponseMessage response = GlobalVariables.client.GetAsync("/Login?id=" + ul.Email + "&pass="******"UserId", result.User_Id);
                    ViewBag.successMsg            = "LoggedIn Successfully";
                    GlobalVariables.isLoggedIn    = true;
                    GlobalVariables.SessionUserId = result.User_Id;
                    GlobalVariables._user         = result;
                }
                catch (Exception ex)
                {
                    ViewBag.LoginError = "There Was An Error Try Again!!!";
                    return(View());
                }



                //Login lgn = new Login() { UserId = ul.Email , Password = ul.Password };
                // ViewBag.user = ul.Email;
                // @Context.Session.GetString("username")
                // HttpContext.Session.SetString("username", username);
                //ViewBag.user = HttpContext.Session.GetString("UserId");
                //return RedirectToPage("index");
                return(View("~/Views/Home/Index.cshtml"));
            }
            return(View());
        }
        public IActionResult SignUp(SignUp ul)
        {
            if (ModelState.IsValid)
            {
                Register dto = new()
                {
                    Email_Id  = ul.Email,
                    FirstName = ul.FirstName,
                    LastName  = ul.LastName,
                    Mobile_No = ul.Mobile_No,
                    Password  = ul.Password,
                    UserNo    = 0,
                    User_Id   = ul.UserId
                };

                HttpResponseMessage response = GlobalVariables.client.PostAsJsonAsync("/Register", dto).Result;
                AppDTO result = response.Content.ReadAsAsync <AppDTO>().Result;
                if (result.IsLoggedIn == false)
                {
                    TempData["SuccessMsg"] = result.ErrotMsg;
                    return(View(TempData));
                }

                HttpContext.Session.SetString("UserId", result.User_Id);

                GlobalVariables.isLoggedIn = true;

                GlobalVariables.SessionUserId = result.User_Id;

                GlobalVariables._user = result;

                TempData["SuccessMsg"] = "Registered Successfully";


                return(View("~/Views/Home/Index.cshtml"));
            }
            return(View());
        }
    }
Exemplo n.º 20
0
        public AppDTO FindApp(string appName)
        {
            app = _appRepository
                  .GetByLambda(x =>
                               x.Name == appName).FirstOrDefault();

            userApp = _userAppRepository
                      .GetByLambda(x =>
                                   x.AppsId == app.Id).ToList <UserApp>();

            foreach (UserApp userAppRel in userApp)
            {
                users.Add(
                    _userRepository
                    .GetByLambda(x =>
                                 x.Id == userAppRel.UsersId).FirstOrDefault());
            }


            users = users.Distinct().ToList <User>();

            appDTO = new AppDTO()
            {
                Name       = app.Name,
                Genre      = app.Genre,
                LastUpdate = app.LastUpdate,
                AppBrand   = app.AppBrand
            };

            foreach (User user in users)
            {
                appDTO.developersSet.Add(user);
            }

            return(appDTO);
        }
Exemplo n.º 21
0
 public IActionResult Post([FromBody] AppDTO value)
 {
     return(Success());
 }
Exemplo n.º 22
0
 public ActionResult Create(AppDTO appParam)
 {
     _appService.Add(appParam);
     return(Json("Sucess"));
 }
Exemplo n.º 23
0
 public ActionResult Edit(AppDTO appParam)
 {
     _appService.Update(appParam);
     return(Json("Sucess"));
 }
Exemplo n.º 24
0
 public IActionResult RadioButtonAction1(AppDTO model)
 {
     return(View());
 }
Exemplo n.º 25
0
 public AppDTO GetAppDTO(int id)
 {
     return(AppDTO.AppToDto(Get(id).Result.Value));
 }