public DataTransfer <PutOutput> Update(PutInput Input) { DataTransfer <PutOutput> transer = new DataTransfer <PutOutput>(); SystemProcess systemprocessinput = new SystemProcess(); SystemProcess systemprocessoutput = new SystemProcess(); PutOutput output = new PutOutput(); systemprocessinput.CopyFrom(Input); SystemProcess systemprocess = _iSystemProcessRepository.GetSystemProcess(systemprocessinput.SystemProcessId); if (systemprocess != null) { systemprocessoutput = _iSystemProcessRepository.UpdateSystemProcess(systemprocessinput); if (systemprocessoutput != null) { output.CopyFrom(systemprocessoutput); transer.IsSuccess = true; transer.Data = output; } else { transer.IsSuccess = false; transer.Errors = new string[1]; transer.Errors[0] = "Error: Could not update."; } } else { transer.IsSuccess = false; transer.Errors = new string[1]; transer.Errors[0] = "Error: Record not found."; } return(transer); }
public DataTransfer <PutOutput> Update(PutInput Input) { DataTransfer <PutOutput> transer = new DataTransfer <PutOutput>(); IList <string> errors = Validator.Validate(Input); if (errors.Count == 0) { PerformanceStatistic performancestatisticinput = new PerformanceStatistic(); PerformanceStatistic performancestatisticoutput = new PerformanceStatistic(); PutOutput output = new PutOutput(); performancestatisticinput.CopyFrom(Input); PerformanceStatistic performancestatistic = _iPerformanceStatisticRepository.GetPerformanceStatistic(performancestatisticinput.PerformanceStatisticId); if (performancestatistic != null) { performancestatisticoutput = _iPerformanceStatisticRepository.UpdatePerformanceStatistic(performancestatisticinput); if (performancestatisticoutput != null) { output.CopyFrom(performancestatisticoutput); transer.IsSuccess = true; transer.Data = output; } else { transer.IsSuccess = false; transer.Errors = new string[1]; transer.Errors[0] = "Error: Could not update."; } } else { transer.IsSuccess = false; transer.Errors = new string[1]; transer.Errors[0] = "Error: Record not found."; } } else { transer.IsSuccess = false; transer.Errors = errors.ToArray <string>(); } return(transer); }
public HttpResponseMessage Put(PutInput input) { try { var account = this.repo.GetAccountByName(input.Name); if (account == null) { throw new Exception($"cat not find account name:{input.Name}"); } var depositResult = this.ooc.Deposit(account, input.Points); if (depositResult == DepositResult.NotEnoughPoints) { throw new Exception($"{nameof(DepositResult.NotEnoughPoints)}"); } return(this.Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { Console.WriteLine(ex.Message); return(this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }