Ejemplo n.º 1
0
        public override void SetbyView(TalentView view, bool ignoreMod = false)
        {
            int taw;
            var talent = this.Get(view.ID);

            if (ignoreMod)
            {
                taw = view.TAW;
            }
            else
            {
                taw = view.TAW - this.GetModTaW(talent);
            }

            if (typeof(AbstractTalentFighting).IsAssignableFrom(talent.GetType()))
            {
                var fightingTalent = (AbstractTalentFighting)talent;
                this.talentRepository.SetTalent(
                    view.ID,
                    taw,
                    view.DeductionSelected?.ID,
                    view.AT - GetModAT(fightingTalent),
                    view.PA - GetModPA(fightingTalent),
                    view.BL - GetModBL(fightingTalent));
            }
            else
            {
                this.talentRepository.SetTalent(
                    view.ID,
                    taw,
                    view.DeductionSelected?.ID);
            }
        }
Ejemplo n.º 2
0
        private TalentView CreateTalentView(ITalent item)
        {
            var newItem = new TalentView()
            {
                ID                = item.ID,
                Name              = item.Name,
                Probe             = GetProbeString(item),
                BE                = item.BE,
                TAW               = GetMaxTaw(item),
                DeductionText     = this.GetDeductionText(item),
                DeductionList     = this.GetDeductionViewList(item),
                DeductionSelected = this.GetDeductionView(item)
            };
            var talentType = item.GetType();

            if (typeof(AbstractTalentGeneral).IsAssignableFrom(talentType))
            {
                var innerItem = (AbstractTalentGeneral)item;
                newItem.ProbeString     = innerItem.GetProbeText();
                newItem.RequirementText = GetRequirementText(innerItem);
            }
            if (typeof(AbstractTalentFighting).IsAssignableFrom(talentType))
            {
                var innerItem = (AbstractTalentFighting)item;
                newItem.AT = GetATMax(innerItem);
                newItem.PA = GetPAMax(innerItem);
                newItem.BL = GetBLMax(innerItem);
            }

            return(newItem);
        }
Ejemplo n.º 3
0
        public Task <Response> Post(TalentView inputTalent)
        {
            try
            {
                Response returnedResponse;

                returnedResponse = GetAll().Result;
                if (returnedResponse.HasError)
                {
                    return(Task.FromResult <Response>(returnedResponse));
                }

                Talent talentInfo = inputTalent.GetBase();
                talentInfo.Id        = Guid.NewGuid().ToString();
                talentInfo.ShortName = talentInfo.Name.Replace(" ", string.Empty);

                Talent[]      talentsAr   = (Talent[])returnedResponse.Payload;
                List <Talent> talentsList = talentsAr.ToList();
                talentsList.Add(talentInfo);
                string newTalents = JsonConvert.SerializeObject(talentsList.ToArray(), Formatting.Indented);

                returnedResponse = _IAwsService.awsS3_UploadTextAsync(
                    _AmazonS3Client,
                    _Csc_AwsS3Settings.Bucket,
                    _Csc_AwsS3Settings.Talents_FileKey,
                    newTalents).Result;
                if (returnedResponse.HasError)
                {
                    return(Task.FromResult <Response>(returnedResponse));
                }

                IFormFile photo = inputTalent.Photo;
                using (Stream stream = photo.OpenReadStream())
                {
                    returnedResponse = _IAwsService.awsS3_UploadStreamAsync(
                        _AmazonS3Client,
                        _Csc_AwsS3Settings.Bucket,
                        "Talent_Photos/" + talentInfo.Id + ".jpg",
                        stream,
                        true).Result;
                }
                if (returnedResponse.HasError)
                {
                    return(Task.FromResult <Response>(returnedResponse));
                }

                return(Task.FromResult <Response>(new Response
                {
                    HttpStatus = HttpStatusCode.OK
                }));
            }
            catch (Exception e)
            {
                return(Task.FromResult <Response>(new Response
                {
                    HttpStatus = HttpStatusCode.InternalServerError,
                    ExceptionPayload = e
                }));
            }
        }
Ejemplo n.º 4
0
 public abstract void SetbyView(TalentView view, bool ignoreMod   = false);