Esempio n. 1
0
        //public async Task<InpowerResult> getAllBooks()
        //{
        //    InpowerResult resp = null;
        //    try
        //    {

        //        resp = await _helper.Get<InpowerResult>(GlobalConstant.BookShelfUrls.getAllBooksUrl.ToString());
        //        return resp;
        //    }
        //    catch (Exception ex)
        //    {
        //        CrashReportService crashReport = new CrashReportService();
        //        CrashReportModel CR = new CrashReportModel();
        //        CR.Filename = "BookShelfService";
        //        CR.Eventname = "GetAllBooks";
        //        // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
        //        CR.ErrorMsg = ex.Message + ex.StackTrace;
        //        await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);
        //        return resp;
        //    }
        //}

        public async Task <InpowerResult> GetAllBooks(PaginationModel paginationModel)
        {
            BooksMapViewModel model = new BooksMapViewModel();

            model.IsRead      = paginationModel.Status;
            model.SkipRecords = paginationModel.SkipRecords;
            model.TakeRecords = paginationModel.TakeRecords;
            model.SearchText  = (String.IsNullOrEmpty(paginationModel.SearchText)?"": paginationModel.SearchText);
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Post <BooksMapViewModel>(model, GlobalConstant.BookShelfUrls.getAllBooksUrl.ToString());

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "BookShelfService";
                CR.Eventname = "PostBook";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
        public async Task <InpowerResult> SendCrashReport(CrashReportModel ev, string Url)
        {
            InpowerResult resp;

            resp = await _helper.Post <CrashReportModel>(ev, Url);

            return(resp);
        }
Esempio n. 3
0
 public CrashReportAsync(string fileName, string methodName, string error)
 {
     cr              = new CrashReportModel();
     this.fileName   = fileName;
     this.methodName = methodName;
     this.error      = error;
     jResult         = new JsonResult();
 }
        private async Task <ObjectResult> UpdateForAdministrator(CrashReportModel updatedCrashReport)
        {
            if (await _mainDbContext.UserCrashReports.FindAsync(-1, updatedCrashReport.Id) is { } userCrashReport)
            {
                userCrashReport.Status  = updatedCrashReport.Status;
                userCrashReport.Comment = updatedCrashReport.Comment;
                await _mainDbContext.SaveChangesAsync();

                return(StatusCode((int)HttpStatusCode.OK, new StandardResponse("Updated successful!")));
            }
        public async Task <ActionResult> Update([FromBody] CrashReportModel updatedCrashReport)
        {
            if (User.IsInRole(ApplicationRoles.Administrator) || User.IsInRole(ApplicationRoles.Moderator))
            {
                return(await UpdateForAdministrator(updatedCrashReport));
            }

            if (!HttpContext.User.HasClaim(c => c.Type == "nmapikey") || HttpContext.User.Claims.FirstOrDefault(c => c.Type == "nmapikey") is not {
            } apiKeyClaim)
            {
                return(StatusCode((int)HttpStatusCode.BadRequest, new StandardResponse("Invalid Bearer!")));
            }

            if (await _nexusModsAPIClient.ValidateAPIKey(apiKeyClaim.Value) is not {
            } validateResponse)
            {
                return(StatusCode((int)HttpStatusCode.Unauthorized, new StandardResponse("Invalid NexusMods API Key from Bearer!")));
            }

            return(await UpdateForUser(validateResponse.UserId, updatedCrashReport));
        }
Esempio n. 6
0
        public async Task <InpowerResult> UpdateBook(BooksMapViewModel model)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Post <BooksMapViewModel>(model, GlobalConstant.BookShelfUrls.UpdateBookUrl.ToString());

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "BookShelfService";
                CR.Eventname = "PostBook";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
Esempio n. 7
0
        public async Task <InpowerResult> PostGroupMessageService(GroupMessageRequestViewModel groupSend)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Post <GroupMessageRequestViewModel>(groupSend, GlobalConstant.GroupChatUrls.PostMessageGroupUrl.ToString());

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "Registration";
                CR.Eventname = "AccountService";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
Esempio n. 8
0
        public async Task <InpowerResult> GetGroupMessagesUpto(long groupId, string unixTimeStamp)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Get <InpowerResult>(GlobalConstant.GroupChatUrls.GetGroupMessagesUptoUrl.ToString() + "?groupId=" + groupId + "&unixTicks=" + unixTimeStamp);

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "Registration";
                CR.Eventname = "AccountService";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
Esempio n. 9
0
        public async Task <InpowerResult> PostSuggestInterest(SuggestedInterestsRequestViewModel model)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Post <SuggestedInterestsRequestViewModel>(model, GlobalConstant.CommonUrls.PostSuggestInterestServiceUrl);

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "Interst";
                CR.Eventname = "InetrestService";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
Esempio n. 10
0
        public async Task <InpowerResult> getChatAll(UserRequestViewModel model)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Get <InpowerResult>(GlobalConstant.ChatUrls.getAllChatServiceUrl.ToString());

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "Registration";
                CR.Eventname = "AccountService";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
Esempio n. 11
0
        public async Task <InpowerResult> PostUnBlockUserInterest(userdetails BlockUser)
        {
            InpowerResult resp = null;

            try
            {
                resp = await _helper.Post(BlockUser, GlobalConstant.SettingUrls.postUnBlockUserUrl);

                return(resp);
            }
            catch (Exception ex)
            {
                CrashReportService crashReport = new CrashReportService();
                CrashReportModel   CR          = new CrashReportModel();
                CR.Filename  = "Interst";
                CR.Eventname = "InetrestService";
                // CR.UserID = GlobalClass.UserID == null ? "0" : GlobalClass.UserID;
                CR.ErrorMsg = ex.Message + ex.StackTrace;
                await crashReport.SendCrashReport(CR, GlobalConstant.CrashUrl);

                return(resp);
            }
        }
Esempio n. 12
0
        public async Task <JsonResult> SendCrashReport(CrashReportModel ev)
        {
            JsonResult resp = new JsonResult {
                Success = false, Message = ""
            };

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(GlobalClass.BaseUrl);
                var json = JsonConvert.SerializeObject(ev);

                var sendContent = new StringContent(json, Encoding.UTF8, "application/json");
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = null;
                try
                {
                    response = await client.PostAsync(client.BaseAddress + "Log/CrashReport", sendContent);
                }
                catch (Exception ex)
                {
                    resp.Message = ex.Message;
                }
                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <JsonResult>(content));
                }
                else
                {
                    var content = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <JsonResult>(content));
                }
            }
        }
Esempio n. 13
0
 public Task <JsonResult> PostCrashReport(CrashReportModel ev)
 {
     return(repo.SendCrashReport(ev));
 }