Ejemplo n.º 1
0
        public async Task <IActionResult> GetCategories()
        {
            var response = new ListModelResponse <CategoryModel>() as IListModelResponse <CategoryModel>;

            var query = await _categoryService.GetCategoriesAsync();

            if (query == null || !query.Any())
            {
                _logger.Warning(MessageTemplate, ProtocolName(), RequestMethod(), TraceIdentifierName(), LoggingEvents.LIST_ITEMS_NOTFOUND, "LIST_ITEMS_NOTFOUND", RequestPath());

                response.HasError     = true;
                response.ErrorMessage = "LIST_ITEMS_NOTFOUND";
                response.ErrorCode    = LoggingEvents.LIST_ITEMS_NOTFOUND;
                return(response.ToHttpResponse());
            }

            var result = query.Select(x => new CategoryModel()
            {
                Id   = x.Id,
                Name = x.Name
            });

            response.Model   = result;
            response.Message = string.Format("Total of records: {0}", response.Model.Count());

            _logger.Information(MessageTemplate, ProtocolName(), RequestMethod(), TraceIdentifierName(), LoggingEvents.LIST_ITEMS, "LIST_ITEMS", RequestPath());
            return(response.ToHttpResponse());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetBooks(int?pageSize = 25, int?pageNumber = 1, string name = null)
        {
            var response = new ListModelResponse <BookListModel>() as IListModelResponse <BookListModel>;

            try
            {
                response.PageSize   = (int)pageSize;
                response.PageNumber = (int)pageNumber;

                var query = await _bookService.GetBooksAsync(response.PageSize, response.PageNumber, name);

                if (!query.Any())
                {
                    _logger.Warning(MessageTemplate, ProtocolName(), RequestMethod(), TraceIdentifierName(), LoggingEvents.LIST_ITEMS_NOTFOUND, "LIST_ITEMS_NOTFOUND", RequestPath());

                    response.HasError     = true;
                    response.ErrorMessage = "LIST_ITEMS_NOTFOUND";
                    response.ErrorCode    = LoggingEvents.LIST_ITEMS_NOTFOUND;
                    return(response.ToHttpResponse());
                }

                var result = query.Select(x => new BookListModel()
                {
                    Isbn        = x.Isbn,
                    Publisher   = x.Publisher,
                    Stock       = x.Stock,
                    Language    = x.Language,
                    AuthorModel = new AuthorModel()
                    {
                        Id        = _authorService.GetAuthorByIdAsync(x.AuthorId).Result.Id,
                        FirstName = _authorService.GetAuthorByIdAsync(x.AuthorId).Result.FirstName,
                        LastName  = _authorService.GetAuthorByIdAsync(x.AuthorId).Result.LastName
                    },
                    CategoryModel = new CategoryModel()
                    {
                        Id   = _categoryService.GetCategoryByIdAsync(x.CategoryId).Result.Id,
                        Name = _categoryService.GetCategoryByIdAsync(x.CategoryId).Result.Name,
                    },
                    Name              = x.Name,
                    Published         = x.Published,
                    CreatedDate       = x.CreatedDate,
                    Id                = x.Id,
                    Description       = x.Description,
                    Hardcover         = x.Hardcover,
                    ProductDimensions = x.ProductDimensions
                }).ToList();

                response.Model   = result;
                response.Message = string.Format("Total of records: {0}", response.Model.Count());
            }
            catch (Exception ex)
            {
                response.HasError     = true;
                response.ErrorMessage = ex.Message;
            }

            _logger.Information(MessageTemplate, ProtocolName(), RequestMethod(), TraceIdentifierName(), LoggingEvents.LIST_ITEMS, "LIST_ITEMS", RequestPath(), RequestPathString());
            return(response.ToHttpResponse());
        }
Ejemplo n.º 3
0
        public IActionResult GetCuisinesV2(ResourceParameter parameters)
        {
            var response = new ListModelResponse <MainMenuDto>() as IListModelResponse <MainMenuDto>;

            //throw new InvalidOperationException("This is an unhandled exception");
            //throw new ECafeException("error occured");

            if (!_propertyMappingService.ValidMappingExistsFor <MainMenuDto, MainMenu>(parameters.OrderBy))
            {
                logger.LogError($"Invalid mapping requested in {this.GetType().Name} Method Name");
                return(response.ToErrorResponse("Invalid mapping requested", HttpStatusCode.BadRequest));
            }

            if (!typeHelperService.TypeHasProperties <MainMenuDto>(parameters.Fields))
            {
                return(response.ToErrorResponse("Invalid properties name requested", HttpStatusCode.BadRequest));
            }

            var results = _mainMenuGetService.GetAll(parameters);

            //***Create pagination header
            var paginationMetadata = ResourceUri <MainMenu> .CreatePaginationHeader(parameters, results, urlHelper, "GetCuisines");

            Response.Headers.Add("X-Pagination", Newtonsoft.Json.JsonConvert.SerializeObject(paginationMetadata));

            //***Mapping Entity to Dto
            var medicineTypes = AutoMapper.Mapper.Map <IEnumerable <MainMenuDto> >(results);

            response.ShapeModel = medicineTypes.ShapeData(parameters.Fields);
            response.Model      = new List <MainMenuDto>();
            response.Message    = $"Total of records: {response.ShapeModel.Count()}";
            response.PageSize   = parameters.PageSize;
            response.PageNumber = parameters.PageNumber;
            return(response.ToHttpResponse());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> GetRegistrations([FromQuery] int eventId)
        {
            var response = new ListModelResponse <EventRegistration>()
                           as IListModelResponse <EventRegistration>;

            try
            {
                if (eventId < 1)
                {
                    throw new Exception("Athlete Id is null");
                }
                response.Model = await Task.Run(() =>
                {
                    IEnumerable <EventRegistration> regs = _context.GetAll(eventId);
                    if (regs == null)
                    {
                        throw new Exception("No registrations");
                    }
                    return(regs);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> GetTestStepsAsync(int projectId, int scenarioId, int subscenarioId)
        {
            var response = new ListModelResponse <TestStepViewModel>();

            try
            {
                // response.PageSize = (Int32)pageSize;
                // response.PageNumber = (Int32)pageNumber;
                // var subscenariosDataModel = await _subscenarioRepository
                //   .GetSubScenarios(projectId, scenarioId);

                var teststepsDataModel = await _teststepRepository
                                         .GetTestStepsAsync(projectId, scenarioId, subscenarioId);

                response.Model = teststepsDataModel.Select(item => item.ToViewModel());

                response.Message = String.Format("Total of records: {0}", response.Model.Count());
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 6
0
        public IActionResult GetAll(int?pageSize = 10, int?pageNumber = 1, string q = null)
        {
            var response = new ListModelResponse <UserGridResource>
            {
                PageNumber = (int)pageNumber,
                PageSize   = (int)pageSize
            };
            var query = _userRepository.Query().Where(x => x.IsActive)
                        .Include(x => x.UserRoles).ThenInclude(ur => ur.Role)
                        .Skip((response.PageNumber - 1) * response.PageSize)
                        .Take(response.PageSize).ToList();

            if (!string.IsNullOrEmpty(q) && query.Any())
            {
                q     = q.ToLower();
                query = query.Where(x => x.FullName.ToLower().Contains(q.ToLower()) ||
                                    x.Email.ToLower().Contains(q.ToLower()) ||
                                    x.Phone.ToLower().Contains(q.ToLower())).ToList();
            }

            try
            {
                response.Model = _mapper.Map <IEnumerable <User>, IEnumerable <UserGridResource> >(query);

                response.Message = string.Format("Total of records: {0}", response.Model.Count());
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 7
0
        public async Task <IHttpActionResult> GetAssigned(int id = 0, int page = 0, String namefilter = "",
                                                          String serverNamefilter = "", String versionFilter = "", String sqlversions = "")
        {
            InstanceRepository repository = new InstanceRepository(new MsSqlMonitorEntities());
            IListModelResponse <InstanceViewModel> response = new ListModelResponse <InstanceViewModel>();

            try
            {
                PaginatedInstances data = await repository.GetAssignedInstancesAsync(id, page, namefilter, serverNamefilter, versionFilter, sqlversions);

                response.Model = data.List.Select(i => i.ToViewModel());

                response.PagesCount = data.PageCount;
                response.PageNumber = data.Page;
                response.PageSize   = data.PageSize;
                response.Versions   = data.Versions;
            }
            catch (Exception e)
            {
                response.DidError     = true;
                response.ErrorMessage = e.Message;
            }

            return(response.ToHttpResponse(Request));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> GetUsersAsync()
        {
            var response = new ListModelResponse <UserViewModel>();

            try
            {
                // response.PageSize = (Int32)pageSize;
                // response.PageNumber = (Int32)pageNumber;

                var usersDataModel = await _userRepository
                                     .GetUsers();

                response.Model = usersDataModel.Select(item => item.ToViewModel());


                response.Message = String.Format("Total of records: {0}", response.Model.Count());
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 9
0
        public IActionResult Get()
        {
            int pageNumber = 1; int pageSize = 10;
            var response = new ListModelResponse <UserType>() as IListModelResponse <UserType>;

            try
            {
                if (ModelState.IsValid)
                {
                    var data             = _userType.GetAllUserTypes();
                    int skip             = (pageNumber - 1) * pageSize;
                    int totalRecordCount = data.Count();
                    int pageCount        = totalRecordCount > 0 ? (int)Math.Ceiling(totalRecordCount / (double)pageSize) : 0;

                    response.StatusCode = (int)HttpStatusCode.OK;
                    response.Count      = data.Count();
                    response.Success    = "Y";
                    response.PageNumber = pageNumber;
                    response.PageSize   = pageSize;
                    response.Data       = data.ToList();
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = (int)HttpStatusCode.InternalServerError;
                response.Message    = ex.Message;
                response.Count      = 0;
                response.Success    = "N";
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> GetEventByRoute([FromQuery] int routeId)
        {
            var response = new ListModelResponse <Event>()
                           as IListModelResponse <Event>;

            try
            {
                if (routeId < 1)
                {
                    throw new Exception("User Id is null");
                }
                response.Model = await Task.Run(() =>
                {
                    IEnumerable <Event> evnt = _context.GetEventByRoute(routeId);
                    if (evnt == null)
                    {
                        throw new Exception("Event does not Exist");
                    }
                    return(evnt);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 11
0
        public IActionResult DeleteUser(int id, int userId)
        {
            var response = new ListModelResponse <UserListVM>() as IListModelResponse <UserListVM>;

            try
            {
                var data = _userService.GetUserById(id);
                if (data == null)
                {
                    response.StatusCode = (int)HttpStatusCode.InternalServerError;
                    response.Message    = "Something went wrong when deleting data.";
                    response.Success    = "N";
                }
                else
                {
                    data.nactive = 0;
                    _userService.Update(data);
                    _userService.Commit();

                    response.Message    = "Data successfully deleted.";
                    response.StatusCode = (int)HttpStatusCode.OK;
                    response.Success    = "Y";
                    response.Data       = _userService.GetAllUserLists();
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = (int)HttpStatusCode.InternalServerError;
                response.Message    = ex.Message;
                response.Success    = "N";
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 12
0
        public IActionResult GetAll(int?pageSize, int?pageNumber, string q = null)
        {
            var response = new ListModelResponse <CategoryBooking>
            {
                PageSize   = (int)pageSize,
                PageNumber = (int)pageNumber
            };
            var query = _cateBookingRepository.Query().Skip((response.PageNumber - 1) * response.PageSize)
                        .Take(response.PageSize).ToList();

            if (!string.IsNullOrEmpty(q) && query.Any())
            {
                q     = q.ToLower();
                query = query.Where(x => x.BookingName.ToLower().Contains(q.ToLower())).ToList();
            }

            try
            {
                response.Model = _mapper.Map(query, response.Model);

                response.Message = string.Format("Total of records: {0}", response.Model.Count());
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
                _logger.LogError(ex.InnerException.ToString());
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> GetClubMembers([FromQuery] int clubId)
        {
            var response = new ListModelResponse <ClubMember>()
                           as IListModelResponse <ClubMember>;

            try
            {
                if (clubId < 1)
                {
                    throw new Exception("Club Id is null");
                }
                response.Model = await Task.Run(() =>
                {
                    IEnumerable <ClubMember> member = _context.GetMembers(clubId);
                    if (member == null)
                    {
                        throw new Exception("Club Member does not Exist");
                    }
                    return(member);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> GetUserClubs([FromQuery] string userId)
        {
            var response = new ListModelResponse <Club>()
                           as IListModelResponse <Club>;

            try
            {
                if (userId == null)
                {
                    throw new Exception("User Id is null");
                }
                response.Model = await Task.Run(() =>
                {
                    IEnumerable <Club> clubs = _context.GetUserClubs(userId);
                    if (clubs == null)
                    {
                        throw new System.ArgumentNullException("Clubs do not does not Exist");
                    }
                    return(clubs);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 15
0
        public async Task <IActionResult> GetPackResultsAsync(int packId, int projectId, DateTime fromDate, DateTime toDate)
        {
            var response = new ListModelResponse <PackResultViewModel>();
            List <PackResultViewModel> viewModel = new List <PackResultViewModel>();

            try
            {
                var packResultsDataModel = await _packResultRepository.GetPackResults(packId, projectId, fromDate, toDate);

                List <String> tstGroupIds     = packResultsDataModel.Select(x => x.TestGroupId).ToList();
                var           lstPieChartData = await _packResultRepository.GetPieChartDetails(packId.ToString(), tstGroupIds);

                foreach (var pckresults in packResultsDataModel)
                {
                    var pieChartData = lstPieChartData.FirstOrDefault(x => x.TestGroupId == pckresults.TestGroupId);

                    viewModel.Add(pckresults.ToViewModel(pieChartData));
                }
                response.Model = viewModel;
                //.Select(item => item.ToViewModel())
                //.ToListAsync();

                response.Message = String.Format("Total of records: {0}", response.Model.Count());
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
        public async Task <IActionResult> GetProducts(int?pageSize = 10, int?pageNumber = 1, string name = null)
        {
            var response = new ListModelResponse <ProductViewModel>() as IListModelResponse <ProductViewModel>;

            try
            {
                response.PageSize   = (int)pageSize;
                response.PageNumber = (int)pageNumber;

                response.Model = await Task.Run(() =>
                {
                    var data = ProductRepository
                               .GetProducts(response.PageSize, response.PageNumber, name).ToList();
                    return(ProductRepository
                           .GetProducts(response.PageSize, response.PageNumber, name)
                           .Select(item => item.ToViewModel())
                           .ToList());
                });

                response.Message = string.Format("Total of records: {0}", response.Model.Count());
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> GetUserRoutes([FromQuery] string userId)
        {
            var response = new ListModelResponse <Route>()
                           as IListModelResponse <Route>;

            try
            {
                if (userId == null)
                {
                    throw new Exception("User Id is null");
                }
                response.Model = await Task.Run(() =>
                {
                    IEnumerable <Route> routes = _context.GetUserRoutes(userId);
                    if (routes == null)
                    {
                        throw new Exception("There are no routes");
                    }
                    return(routes);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
        public IActionResult GetAll(int page, string keyword, int pageSize = 3)
        {
            var model    = _productCategoryService.GetAll(keyword);
            int totalRow = model.Count();

            var query        = model.OrderBy(x => x.ID).Skip(page * pageSize).Take(pageSize);
            var responseData = Mapper.Map <IEnumerable <ProductCategoryViewModel> >(query);

            var response = new ListModelResponse <ProductCategoryViewModel>() as IListModelResponse <ProductCategoryViewModel>;

            try
            {
                response.TotalRows = totalRow;
                //rows per page
                response.PageSize   = query.Count();
                response.PageNumber = page;
                response.TotalPages = (int)Math.Ceiling((double)totalRow / pageSize);
                response.Model      = responseData;

                response.Message = String.Format("Total of records: {0}", response.Model.Count());
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
        public async Task <IActionResult> GetPurchaseOrderStatusesAsync(Int32?pageSize = 10, Int32?pageNumber = 1, String name = null)
        {
            var response = new ListModelResponse <PurchaseOrderStatusViewModel>() as IListModelResponse <PurchaseOrderStatusViewModel>;

            try
            {
                response.PageSize   = (Int32)pageSize;
                response.PageNumber = (Int32)pageNumber;

                response.Model = await Task.Run(() =>
                {
                    return(_RESTfulAPI_Repository
                           .GetPurchaseOrderStatuses(response.PageSize, response.PageNumber, name)
                           .Select(item => item.ToViewModel())
                           .ToList());
                });

                response.Info = String.Format("Total of records: {0}", response.Model.Count());
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> GetClubEvents([FromQuery] int clubId)
        {
            var response = new ListModelResponse <Event>()
                           as IListModelResponse <Event>;

            try
            {
                if (clubId <= 0)
                {
                    throw new Exception("Club Id is null");
                }
                response.Model = await Task.Run(() =>
                {
                    IEnumerable <Event> evnts = _context.GetClubEvents(clubId);;
                    if (evnts == null)
                    {
                        throw new Exception("No Events");
                    }
                    return(evnts);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 21
0
        public IActionResult GetAll(int?pageSize, int?pageNumber, string q = null)
        {
            var response = new ListModelResponse <AreaResource>
            {
                PageSize   = (int)pageSize,
                PageNumber = (int)pageNumber
            };
            var query = _areaRepository.Query().Include(x => x.Functions)
                        .Skip((response.PageNumber - 1) * response.PageSize)
                        .Take(response.PageSize).ToList();

            if (!string.IsNullOrEmpty(q) && query.Any())
            {
                q     = q.ToLower();
                query = query.Where(x => x.AreaName.ToLower().Contains(q.ToLower()) ||
                                    x.CodeArea.ToLower().Contains(q.ToLower())).ToList();
            }

            try
            {
                response.Model = _mapper.Map(query, response.Model);

                response.Message = string.Format("Total of records: {0}", response.Model.Count());
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 22
0
        public async Task <IActionResult> GetAthleteEventRuns([FromQuery] int athleteId)
        {
            var response = new ListModelResponse <Run>()
                           as IListModelResponse <Run>;

            try
            {
                if (athleteId < 1)
                {
                    throw new Exception("Athlete Id is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    IEnumerable <Run> run = _context.GetAthleteEventRuns(athleteId);
                    if (run == null)
                    {
                        throw new Exception("Run does not exist");
                    }
                    return(run);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 23
0
        public async Task <IActionResult> GetMenuDetailBySubMenu(int id)
        {
            var response = new ListModelResponse <MenuDetailDto>() as IListModelResponse <MenuDetailDto>;

            response.Model   = await _menuDetailService.GetMenuDetailByAsync(id);;
            response.Message = $"{ApiMessages.TotalRecords} {response.Model.Count()}";
            return(response.ToHttpResponse());
        }
Ejemplo n.º 24
0
        public async Task <IActionResult> GetLogs(int?pageSize = 10, int?pageNumber = 1, string name = null)
        {
            var response = new ListModelResponse <LogListModel>() as IListModelResponse <LogListModel>;

            try
            {
                response.PageSize   = (int)pageSize;
                response.PageNumber = (int)pageNumber;

                var query = await _loggingService.GetLogsAsync(response.PageSize, response.PageNumber, name);

                var result = query.Select(x => new LogListModel()
                {
                    Id = x.Id,
                    MessageTemplate = x.MessageTemplate,
                    TimeStamp       = x.TimeStamp,
                    Message         = x.Message,
                    Exception       = x.Exception,
                    Level           = x.Level,
                    LogEvent        = x.LogEvent,
                    Properties      = x.Properties,
                }).ToList();

                response.Model   = result;
                response.Message = string.Format("Total of records: {0}", response.Model.Count());

                if (!response.Model.Any())
                {
                    _logger.Warning(MessageTemplate, ProtocolName(), RequestMethod(), TraceIdentifierName(), LoggingEvents.LIST_ITEMS_NOTFOUND, "LIST_ITEMS_NOTFOUND", RequestPath());

                    response.HasError     = true;
                    response.ErrorMessage = "LIST_ITEMS_NOTFOUND";
                    response.ErrorCode    = LoggingEvents.LIST_ITEMS_NOTFOUND;
                    return(response.ToHttpResponse());
                }
            }
            catch (Exception ex)
            {
                _logger.Warning(MessageTemplate, ProtocolName(), RequestMethod(), TraceIdentifierName(), LoggingEvents.METHOD_ERROR, "METHOD_ERROR", RequestPath());

                response.HasError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.ToHttpResponse());
        }
Ejemplo n.º 25
0
        public async Task <IActionResult> SearchAllMenus(string searchText)
        {
            var response = new ListModelResponse <MenuDetailDto>() as IListModelResponse <MenuDetailDto>;
            var entity   = await _menuDetailService.SearchByMenuName(searchText);

            response.Model   = entity;
            response.Message = $"{ApiMessages.TotalRecords} {response.Model.Count()}";
            return(response.ToHttpResponse());
        }
Ejemplo n.º 26
0
        public async Task <IActionResult> GetAllSubMenuWithCount()
        {
            var response = new ListModelResponse <SubMenuResultSet>() as IListModelResponse <SubMenuResultSet>;
            var entity   = await _menuService.GetSubMenuWithSubMenuDetailCount();

            response.Model   = entity;
            response.Message = $"{ApiMessages.TotalRecords} {response.Model.Count()}";
            return(response.ToHttpResponse());
        }
Ejemplo n.º 27
0
        public async Task <IActionResult> GetMenus(Int32?pageSize = 100, Int32?pageNumber = 1, String name = null)
        {
            var response = new ListModelResponse <MenuDto>() as IListModelResponse <MenuDto>;;

            response.PageSize   = (Int32)pageSize;
            response.PageNumber = (Int32)pageNumber;
            response.Model      = await _menuService.GetMenuAsync(response.PageSize, response.PageNumber, name);

            response.Message = $"Total of records: {response.Model.Count()}";
            return(response.ToHttpResponse());
        }
Ejemplo n.º 28
0
        public async Task <IActionResult> GetOrderDetails(Int32?pageSize = 10, Int32?pageNumber = 1, String name = null)
        {
            var response = new ListModelResponse <OrderDto>() as IListModelResponse <OrderDto>;

            response.PageSize   = (Int32)pageSize;
            response.PageNumber = (Int32)pageNumber;
            response.Model      = await _orderService.GetOrderAsync(response.PageSize, response.PageNumber, name);

            response.Message = $"{ApiMessages.TotalRecords} {response.Model.Count()}";
            return(response.ToHttpResponse());
        }
Ejemplo n.º 29
0
        public async Task <IActionResult> GetMenuDetails(Int32?pageSize = 100, Int32?pageNumber = 1, String name = null)
        {
            // throw new InvalidOperationException("This is an unhandled exception");
            var response = new ListModelResponse <MenuDetailDto>() as IListModelResponse <MenuDetailDto>;

            response.PageSize   = (Int32)pageSize;
            response.PageNumber = (Int32)pageNumber;
            response.Model      = await _menuDetailService.GetMenuDetailAsync(response.PageSize, response.PageNumber, name);

            response.Message = $"{ApiMessages.TotalRecords} {response.Model.Count()}";
            return(response.ToHttpResponse());
        }
Ejemplo n.º 30
0
        public async Task <IActionResult> GetBooksByAuthorId(int authorId)
        {
            var response = new ListModelResponse <Book>() as IListModelResponse <Book>;

            var result = await _bookService.GetBooksByAuthorIdAsync(authorId);

            if (result == null || !result.Any())
            {
                _logger.Warning(MessageTemplate, ProtocolName(), RequestMethod(), TraceIdentifierName(), LoggingEvents.LIST_ITEMS_NOTFOUND, "LIST_ITEMS_NOTFOUND", RequestPath());

                response.HasError     = true;
                response.ErrorMessage = "LIST_ITEMS_NOTFOUND";
                response.ErrorCode    = LoggingEvents.LIST_ITEMS_NOTFOUND;
                return(response.ToHttpResponse());
            }

            response.Model   = result;
            response.Message = string.Format("Total of records: {0}", response.Model.Count());

            _logger.Information(MessageTemplate, ProtocolName(), RequestMethod(), TraceIdentifierName(), LoggingEvents.LIST_ITEMS, "LIST_ITEMS", RequestPath());
            return(response.ToHttpResponse());
        }