Ejemplo n.º 1
0
        public JsonResult GetJsonPost()
        {
            informationContentProvider = new InformationContentProvider();
            tokenProvider = new TokenProvider();
            string token = string.Empty;
            InfrastructureModel <InformationContentSingleDataModel> infrastructureModel = new InfrastructureModel <InformationContentSingleDataModel>();

            if (SessionExtension.GetSessionUser(HttpContext.Session) == null)
            {
                token = tokenProvider.GetAnonimToken();
                SessionExtension.Set(HttpContext.Session, "FreeToken", token);
                infrastructureModel = informationContentProvider.GetInformationContentSingleData(new InformationContentPostModel()
                {
                    TokenKey = token
                });
            }
            else
            {
                AppUserModel appUserModel = SessionExtension.GetSessionUser(HttpContext.Session);
                if (appUserModel != null)
                {
                    token = appUserModel.TokenKey;

                    infrastructureModel = informationContentProvider.GetInformationContentSingleData(new InformationContentPostModel()
                    {
                        AppUserId = appUserModel.AppUser.AppUserId, TokenKey = token
                    });
                }
            }
            return(Json(infrastructureModel));
        }
Ejemplo n.º 2
0
        public JsonResult UpdateAppUserInformation(AppUserInformationModel appUserInformationModel)
        {
            Response <bool> response = new Response <bool>();

            appUserProvider = new AppUserProvider();

            AppUserModel appUserModel = SessionExtension.GetSessionUser(HttpContext.Session);

            if (appUserModel != null)
            {
                AppUserModel appUserTokenModel = SessionExtension.GetSessionUser(HttpContext.Session);

                appUserInformationModel.TokenKey = appUserModel.TokenKey;

                appUserInformationModel.AppUserId = appUserModel.AppUser.AppUserId;

                InfrastructureModel <bool> infrastructureModel = appUserProvider.Update(appUserInformationModel);

                response = new Response <bool>
                {
                    Data    = infrastructureModel.ResultStatus,
                    Message = "success",
                    Status  = infrastructureModel.ResultStatus,
                };
            }
            return(Json(response));
        }
Ejemplo n.º 3
0
        public JsonResult ChangePassword(AppUserLoginModel appUserLoginModel)
        {
            Response <bool> response = new Response <bool>();

            appUserProvider = new AppUserProvider();

            AppUserModel appUserModel = SessionExtension.GetSessionUser(HttpContext.Session);

            if (appUserModel != null)
            {
                AppUserModel appUserTokenModel = SessionExtension.GetSessionUser(HttpContext.Session);

                appUserLoginModel.TokenKey  = appUserModel.TokenKey;
                appUserLoginModel.AppUserId = appUserModel.AppUser.AppUserId;

                InfrastructureModel <bool> infrastructureModel = appUserProvider.ChangePassword(appUserLoginModel);

                response = new Response <bool>()
                {
                    Data    = infrastructureModel.ResultModel,
                    Message = infrastructureModel.Message,
                    Status  = true,
                    Refresh = true
                };
            }
            return(Json(response));
        }
        public JsonResult Insert(InformationContentCRUDModel informationContentCRUDModel)
        {
            Response response = new Response();

            try
            {
                informationContentProvider = new InformationContentProvider();

                AppUserModel appUserModel = SessionExtension.GetSessionUser(HttpContext.Session);

                InformationApiContentCRUDModel apiContentCRUDModel = new InformationApiContentCRUDModel()
                {
                    CategoryId  = informationContentCRUDModel.CategoryId,
                    Explanation = informationContentCRUDModel.Explanation,
                    Title       = informationContentCRUDModel.Title,
                    LikeCount   = 0,
                    AuthorId    = appUserModel.AppUser.AppUserId,
                    TokenKey    = appUserModel.TokenKey
                };


                if (informationContentCRUDModel.InformationImage != null)
                {
                    byte[] data;
                    using (var ms = new MemoryStream())
                    {
                        informationContentCRUDModel.InformationImage.CopyTo(ms);
                        apiContentCRUDModel.PostImagePath = Path.GetExtension(informationContentCRUDModel.InformationImage.FileName);
                        data = ms.ToArray();
                    }

                    var fileContent = new ByteArrayContent(data);

                    apiContentCRUDModel.ImageArrayList = fileContent;

                    informationContentProvider.InsertInformationContent(apiContentCRUDModel);
                }
                response = new Response()
                {
                    Message = "success",
                    Status  = true,
                };
            }
            catch (Exception ex)
            {
                response = new Response()
                {
                    Message = "Failed",
                    Status  = false
                };
            }

            return(Json(response));
        }
Ejemplo n.º 5
0
        public JsonResult ResetAllInformation()
        {
            Response <bool> response = new Response <bool>();

            appUserProvider = new AppUserProvider();
            AppUserModel appUserModel = SessionExtension.GetSessionUser(HttpContext.Session);

            if (appUserModel != null)
            {
                AppUserModel appUserTokenModel = SessionExtension.GetSessionUser(HttpContext.Session);

                InfrastructureModel <bool> infrastructureModel = appUserProvider.ResetAllInformationAppUser(appUserTokenModel);

                response = new Response <bool>
                {
                    Data    = infrastructureModel.ResultStatus,
                    Message = infrastructureModel.Message,
                    Status  = infrastructureModel.ResultStatus,
                };
            }
            return(Json(response));
        }
Ejemplo n.º 6
0
        public JsonResult GetAppUserInformation(AppUserLoginModel appUserLoginModel)
        {
            Response <AppUserInformationModel> response = new Response <AppUserInformationModel>();

            appUserProvider = new AppUserProvider();
            AppUserModel appUserModel = SessionExtension.GetSessionUser(HttpContext.Session);

            if (appUserModel != null)
            {
                AppUserModel appUserTokenModel = SessionExtension.GetSessionUser(HttpContext.Session);
                InfrastructureModel <AppUserInformationModel> appUserInformationModel = appUserProvider.GetById(new AppUserLoginModel()
                {
                    AppUserId = appUserModel.AppUser.AppUserId, TokenKey = appUserModel.TokenKey
                });
                response = new Response <AppUserInformationModel>()
                {
                    Data    = appUserInformationModel.ResultModel,
                    Message = "succes",
                    Status  = true
                };
            }
            return(Json(response));
        }