public IHttpActionResult GetTicketsOfUser()
 {
     try
     {
         var user    = _userContextService.GetCurrentUser();
         var tickets = _ticketService.GetTicketsOfUser(user.Id);
         return(Ok(tickets));
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }
        public async Task <IHttpActionResult> GetTicketsForCurrentBankWorker()
        {
            string date = DateTime.Now.ToShortDateString();

            try
            {
                var user    = _userContextService.GetCurrentUser();
                int bankId  = _bankWorkerService.GetBankIdOfCurrentWorker(user.Id);
                var tickets = _ticketService.GetTicketsByDateAndBankId(date, bankId);
                List <Models.TicketForWorker> ticketsForWorker = new List <Models.TicketForWorker>();

                foreach (var t in tickets)
                {
                    var userProfile = await _userManager.GetProfileAsync(t.ClientGuid);

                    Models.TicketForWorker ticket = new Models.TicketForWorker
                    {
                        ClientName    = userProfile.FirstName,
                        ClientSurname = userProfile.LastName,
                        Time          = t.Time,
                        Date          = t.Date,
                    };

                    ticketsForWorker.Add(ticket);
                }

                return(Ok(ticketsForWorker));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
        public IHttpActionResult GetCandidateTaskResultById(int id)
        {
            if (id > 0)
            {
                try
                {
                    var user = _userContextService.GetCurrentUser();
                    var candidateTaskResult = _exercisesResultsServise.GetTaskResultById(id, user.Id);
                    return(Ok(candidateTaskResult));
                }
                catch (Exception)
                {
                    return(InternalServerError());
                }
            }

            return(InternalServerError());
        }
Example #4
0
        public async Task <IHttpActionResult> CreateExchangeRates(Models.ExchangeRatesInfo info)
        {
            var user   = _userContextService.GetCurrentUser();
            int bankId = _bankWorkerService.GetBankIdOfCurrentWorker(user.Id);

            string usdPur  = info.USDPurchase.Replace('.', ',');
            string eurPur  = info.EURPurchase.Replace('.', ',');
            string usdSale = info.USDSale.Replace('.', ',');
            string eurSale = info.EURSale.Replace('.', ',');

            double usdPurchase = Convert.ToDouble(usdPur);
            double eurPurchase = Convert.ToDouble(eurPur);
            double usdSalee    = Convert.ToDouble(usdSale);
            double eurSalee    = Convert.ToDouble(eurSale);

            ExchangeRates rates = new ExchangeRates
            {
                BankId      = bankId,
                USDPurchase = usdPurchase,
                USDSale     = usdSalee,
                EURPurchase = eurPurchase,
                EURSale     = eurSalee
            };

            try
            {
                await _exchangeRatesService.RemoveExchangeRatesByBankIdAsync(bankId);

                await _exchangeRatesService.SaveExchangeRatesAsync(rates);
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Ok());
        }