Example #1
0
        public async Task <ActionResult <ResultSinnerGetSINnerGroupFromSINerById> > GetSINnerGroupFromSINerById([FromRoute] Guid id)
        {
            ResultSinnerGetSINnerGroupFromSINerById res;

            try
            {
                if (!_context.SINners.Any(a => a.Id == id))
                {
                    var e = new ArgumentException("SINner with id " + id + " does not exist.");
                    res = new ResultSinnerGetSINnerGroupFromSINerById(e);
                    return(NotFound(res));
                }

                var groupseq = await(from a in _context.SINners.Include(a => a.MyGroup)
                                     .Include(b => b.MyGroup.MySettings)
                                     where a.Id == id
                                     select a.MyGroup).ToListAsync();


                if (!groupseq.Any())
                {
                    return(NoContent());
                }
                else
                {
                    res = new ResultSinnerGetSINnerGroupFromSINerById(groupseq.FirstOrDefault());
                    return(Ok(res));
                }
            }
            catch (Exception e)
            {
                res = new ResultSinnerGetSINnerGroupFromSINerById(e);
                return(BadRequest(res));
            }
        }
Example #2
0
        public async Task <bool> CheckSINnerStatus()
        {
            try
            {
                if (myUC?.MyCE?.MySINnerFile?.Id == null || myUC.MyCE.MySINnerFile.Id == Guid.Empty)
                {
                    await bUpload.DoThreadSafeAsync(() => bUpload.Text = "SINless Character/Error");

                    return(false);
                }

                using (new CursorWait(this, true))
                {
                    SinnersClient client = StaticUtils.GetClient();
                    ResultSinnerGetSINnerGroupFromSINerById response = await client.GetSINnerGroupFromSINerByIdAsync(myUC.MyCE.MySINnerFile.Id.Value);

                    SINnerGroup objMySiNnerGroup = response.MySINnerGroup;

                    await PluginHandler.MainForm.DoThreadSafeAsync(() =>
                    {
                        if (objMySiNnerGroup != null)
                        {
                            myUC.MyCE.MySINnerFile.MyGroup = objMySiNnerGroup;
                            bUpload.Text         = "Remove from SINners";
                            bGroupSearch.Enabled = true;
                            lUploadStatus.Text   = "Online";
                            bUpload.Enabled      = true;
                        }
                        else
                        {
                            myUC.MyCE.MySINnerFile.MyGroup = null;
                            lUploadStatus.Text             = "Not Online";
                            bGroupSearch.Enabled           = false;
                            bGroupSearch.SetToolTip(
                                "SINner needs to be uploaded first, before he/she can join a group.");
                            bUpload.Enabled = true;
                            bUpload.Text    = "Upload";
                        }
                        //else if (eResponseStatus == HttpStatusCode.NoContent)
                        //{
                        //    myUC.MyCE.MySINnerFile.MyGroup = null;
                        //    lUploadStatus.Text = "Status Code: " + eResponseStatus;
                        //    bGroupSearch.Enabled = true;
                        //    bGroupSearch.SetToolTip(
                        //        "SINner does not belong to a group.");
                        //    bUpload.Text = "Remove from SINners";
                        //    lUploadStatus.Text = "Online";
                        //    bUpload.Enabled = true;
                        //}
                        cbTagCustom.Enabled        = false;
                        TagValueCustomName.Enabled = false;
                    });

                    await this.DoThreadSafeAsync(UpdateTags);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                await bUpload.DoThreadSafeAsync(() => bUpload.Text = "Unknown Status");

                return(false);
            }
            return(true);
        }