Пример #1
0
        public async Task AddAsyncContestantInHeat(ContestantInHeat h)
        {
            await _repo.InsertAsyncContestantInHeat(h);

            var result = new CreateResultViewModel
            {
                UserId = h.UserId,
                HeatId = h.HeatId,
            };
            await _resultService.AddAsync(result);
        }
Пример #2
0
        public void AddContestantInHeat(ContestantInHeat h)
        {
            _repo.InsertContestantInHeat(h);
            var result = new CreateResultViewModel
            {
                UserId = h.UserId,
                HeatId = h.HeatId,
            };

            _resultService.AddAsync(result);
        }
Пример #3
0
        public async Task <CreateResultViewModel> Create(int campaignID, decimal amount)
        {
            CreateResultViewModel result = new CreateResultViewModel(Constants.MSG_RESULT_STATUS_OK, Constants.MSG_RESULT_MESSAGE_OK, Constants.MSG_RESULT_CODE_OK);

            _logger.LogInformation(string.Format("-- ApiManager - Create started"));

            string jsonMessage = "";

            try
            {
                // Read token from ServerLogin
                string token = await _authentication.GetToken();

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(Constants.BASE_ADDRESS);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                    // Read endpoint from CampaignType
                    string endpoint = Constants.API_CREATE;

                    dynamic body = new
                    {
                        CampaignID = campaignID,
                        CardValue  = amount
                    };

                    HttpResponseMessage response = await client.PostAsync(endpoint, new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json"));

                    using (Stream responseStream = await response.Content.ReadAsStreamAsync())
                    {
                        jsonMessage = new StreamReader(responseStream).ReadToEnd();
                    }
                    result = JsonConvert.DeserializeObject <CreateResultViewModel>(jsonMessage);
                }
            }
            catch (Exception ex)
            {
                result.ResultMessage = ex.Message;
                result.ResultStatus  = Constants.MSG_RESULT_STATUS_NOK;
                result.ResultCode    = Constants.MSG_RESULT_CODE_KO;
            }

            return(result);
        }
Пример #4
0
        public async Task AddAsync(CreateResultViewModel model)
        {
            var u = await _adminService.GetUserByIdAsync(model.UserId);

            var c = _adminService.GetCountryNameById(u.Country);
            var n = _adminService.GetNationalityById(u.Nationality);
            var r = new Result
            {
                UserId      = model.UserId,
                HeatId      = model.HeatId,
                Club        = null, //TODO
                Country     = c,
                Created     = DateTime.Now,
                FinalTime   = null,
                Gender      = u.Gender,
                Modified    = DateTime.Now,
                Name        = u.FirstName + " " + u.LastName,
                Nationality = n,
                Notes       = null,
                Status      = 0
            };
            await _repo.AddAsync(r);
        }
Пример #5
0
 public IActionResult Create(CreateResultViewModel card)
 {
     return(View());
 }
Пример #6
0
        public async Task <IActionResult> CreateSvc(int CampaignID, decimal CardValue)
        {
            CreateResultViewModel create = await _svcService.Create(CampaignID, CardValue);

            return(View("Create", create));
        }