public async Task <IActionResult> AddEdit(int?id)
        {
            TourcostDTO tourcost = new TourcostDTO();

            if (id > 0)
            {
                tourcost.Tourcost = await _tourcostCrudService.GetAsync(id);

                tourcost.TourcostDetail = _tourcostDetailCrudService.GetAll(p => p.TourcostId == id).ToList();
            }

            ViewBag.Guide     = new SelectList(await _guideCrudService.GetAllAsync(), "Id", "Name");
            ViewBag.Sector    = new SelectList(await _sectorCrudService.GetAllAsync(), "Id", "Name");
            ViewBag.HotelCatA = new SelectList(await _hotelCrudService.GetAllAsync(p => p.Category == 'A'), "Id", "Code");
            ViewBag.HotelCatB = new SelectList(await _hotelCrudService.GetAllAsync(p => p.Category == 'B'), "Id", "Code");
            ViewBag.HotelCatC = new SelectList(await _hotelCrudService.GetAllAsync(p => p.Category == 'C'), "Id", "Code");

            return(View(tourcost));
        }
Пример #2
0
        private async Task <int> HandleUserIdAsync(string userName)
        {
            var user = await _userService.GetAllAsync(x => x.Username == userName);

            if (user == default || !user.Any())
            {
                throw new AppValidationException(HttpStatusCode.BadRequest,
                                                 _localizer["Address.UserNotFound"].Value);
            }
            return(user.Single().Id);
        }
Пример #3
0
        public async Task <IActionResult> GetInvoiceDetail(int invoiceId)
        {
            try
            {
                var result = await _invoiceDetailCrudService.GetAllAsync(p => p.InvoiceId == invoiceId);

                return(Json(result));
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
        public async Task <IActionResult> Get(int?id)
        {
            try
            {
                if (id == null)
                {
                    var result = await _transportCrudService.GetAllAsync();

                    return(Json(result));
                }
                else
                {
                    var result = _transportCrudService.Get(id);
                    return(Json(result));
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Пример #5
0
        public async Task <IActionResult> GetInvoice(int?id)
        {
            try
            {
                if (id == null)
                {
                    var result = await _invoiceCrudService.GetAllAsync();

                    return(Json(result.OrderByDescending(p => p.CreatedDate)));
                }
                else
                {
                    var result = _invoiceCrudService.Get(id);
                    return(Json(result));
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Пример #6
0
        public async Task <IActionResult> Get(string fileCodeNo)
        {
            try
            {
                if (fileCodeNo == null)
                {
                    var result = await _customerCrudService.GetAllAsync();

                    return(Json(result.OrderByDescending(p => p.CreatedDate)));
                }
                else
                {
                    var result = _customerCrudService.Get(p => p.FileCodeNo == fileCodeNo);
                    return(Json(result));
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Пример #7
0
        public PlanetQueries(ICrudService <Planet> planetService, ILogger <PlanetQueries> logger)
        {
            FieldAsync <ListGraphType <PlanetQueryViewModel> >(
                "getAll",
                "Use this to get all the planets",
                new QueryArguments(),
                async context =>
            {
                try
                {
                    return(await planetService.GetAllAsync());
                }
                catch (Exception ex)
                {
                    logger.LogCritical(ex.Message, ex);
                    return(null);
                }
            });

            FieldAsync <PlanetQueryViewModel>(
                "getById",
                "Use this to get planet info",
                new QueryArguments(new QueryArgument <GuidGraphTypeCustom> {
                Name = "planetId"
            }),
                async context =>
            {
                try
                {
                    var planetId = context.GetArgument <Guid>("planetId");
                    return(await planetService.GetByIdAsync(planetId));
                }
                catch (Exception ex)
                {
                    logger.LogCritical(ex.Message, ex);
                    return(null);
                }
            });
        }
Пример #8
0
        public TeamQueries(ICrudService <Team> teamService, ILogger <TeamQueries> logger)
        {
            FieldAsync <ListGraphType <TeamQueryViewModel> >(
                "getAll",
                "Use this to get all the teams",
                new QueryArguments(),
                async context =>
            {
                try
                {
                    return(await teamService.GetAllAsync());
                }
                catch (Exception ex)
                {
                    logger.LogCritical(ex.Message, ex);
                    return(null);
                }
            });

            FieldAsync <TeamQueryViewModel>(
                "getById",
                "Use this to get team info",
                new QueryArguments(new QueryArgument <GuidGraphTypeCustom> {
                Name = "teamId"
            }),
                async context =>
            {
                try
                {
                    var teamId = context.GetArgument <Guid>("teamId");
                    return(await teamService.GetByIdAsync(teamId));
                }
                catch (Exception ex)
                {
                    logger.LogCritical(ex.Message, ex);
                    return(null);
                }
            });
        }
Пример #9
0
        public ShuttleQueries(ICrudService <Shuttle> shuttleService, ILogger <ShuttleQueries> logger)
        {
            FieldAsync <ListGraphType <ShuttleQueryViewModel> >(
                "getAll",
                "Use this to get all the shuttles",
                new QueryArguments(),
                async context =>
            {
                try
                {
                    return(await shuttleService.GetAllAsync());
                }
                catch (Exception ex)
                {
                    logger.LogCritical(ex.Message, ex);
                    return(null);
                }
            });

            FieldAsync <ShuttleQueryViewModel>(
                "getById",
                "Use this to get shuttle info",
                new QueryArguments(new QueryArgument <GuidGraphTypeCustom> {
                Name = "shuttleId"
            }),
                async context =>
            {
                try
                {
                    var shuttleId = context.GetArgument <Guid>("shuttleId");
                    return(await shuttleService.GetByIdAsync(shuttleId));
                }
                catch (Exception ex)
                {
                    logger.LogCritical(ex.Message, ex);
                    return(null);
                }
            });
        }
Пример #10
0
        public ExplorationQueries(ICrudService <Exploration> explorationService, ILogger <ExplorationQueries> logger)
        {
            FieldAsync <ListGraphType <ExplorationQueryViewModel> >(
                "getAll",
                "Use this to get all the explorations",
                new QueryArguments(),
                async context =>
            {
                try
                {
                    return(await explorationService.GetAllAsync());
                }
                catch (Exception ex)
                {
                    logger.LogCritical(ex.Message, ex);
                    return(null);
                }
            });

            FieldAsync <ExplorationQueryViewModel>(
                "getById",
                "Use this to get exploration info",
                new QueryArguments(new QueryArgument <GuidGraphTypeCustom> {
                Name = "explorationId"
            }),
                async context =>
            {
                try
                {
                    var explorationId = context.GetArgument <Guid>("explorationId");
                    return(await explorationService.GetByIdAsync(explorationId));
                }
                catch (Exception ex)
                {
                    logger.LogCritical(ex.Message, ex);
                    return(null);
                }
            });
        }
Пример #11
0
 public virtual async Task <IEnumerable <T> > GetAllAsync() => await _service.GetAllAsync();
Пример #12
0
 public virtual async Task <ActionResult <IEnumerable <T2> > > GetAll() => Ok(await _service.GetAllAsync());
Пример #13
0
 public async Task <IActionResult> GetAll() => Ok(await _service.GetAllAsync());
        public async Task <IActionResult> Index()
        {
            var tourcost = await _tourcostCrudService.GetAllAsync();

            return(View(tourcost.OrderByDescending(p => p.CreatedDate)));
        }
        public virtual async Task <IEnumerable <TDto> > GetAllAsync()
        {
            var entities = await _service.GetAllAsync();

            return(entities.Select(_ => _mapper.Map <TDto>(_)));
        }
Пример #16
0
 public async Task <IEnumerable <T2> > GetAllAsync() => await _service.GetAllAsync();
Пример #17
0
 public async Task <IHttpActionResult> GetAllAsync() => await ExecuteAsync(async() => await _crudService.GetAllAsync());
        public async Task <IActionResult> GetAccountContacts(Guid accountId)
        {
            var accounts = await _contactService.GetAllAsync();

            return(Ok(accounts.Where(_ => _.AccountId == accountId)));
        }