public async Task <IActionResult> Index()
        {
            try
            {
                var model = new IndexReviewViewModel();

                var userId = this.wrapper.GetLoggedUserId(User);

                var user = await this.userService.GetUserByIdAsync(userId);

                var businessUnit = new BusinessUnitDTO();

                if (user.BusinessUnitId.HasValue)
                {
                    businessUnit = await this.businessUnitService.GetBusinessUnitById(user.BusinessUnitId.Value);
                }
                else
                {
                    return(BadRequest(string.Format(WebConstants.BusinessUniNotAssigned)));
                }

                var reviews = await this.reviewService.GetAllReviewsByModeratorIdAsync(userId);

                model.Reviews      = reviews.Select(x => x.MapFrom()).ToList();
                model.BusinessUnit = businessUnit.MapFrom();
                model.ModeratorId  = userId;

                return(View(model));
            }
            catch (Exception ex)
            {
                log.Error("Unexpected exception occured:", ex);
                return(RedirectToAction("Error", "Home"));
            }
        }
Пример #2
0
        private HebbraCoDbfModel.HebbraCo16Model context = new HebbraCo16Model(); // A database context reference

        // Called when a HTTP GET request comes in at /BusinessUnit
        public IEnumerable <BusinessUnitDTO> Get()
        {
            var allBu = context.BusinessUnits.Where(b => b.Active == true); // Gets a collection of all Business Units where they are not soft deleted
            var dto   = BusinessUnitDTO.buildList(allBu);                   // Passes the collection to the Business Unit Data Transfer Object to be formatted

            return(dto);                                                    // Returns the fomatted data (as JSON or XML, depending on which is chosen)
        }
Пример #3
0
        public IQueryable <BusinessUnitDTO> GetBusinessUnit()
        {
            var allBu = db.BusinessUnits.Where(b => b.Active == true);
            var dto   = BusinessUnitDTO.buildList(allBu);

            return(dto);
        }
Пример #4
0
        public async Task <IHttpActionResult> GetBusinessUnit(int id)
        {
            var bu = db.BusinessUnits.Where(b => b.Active == true).Where(b => b.businessUnitId == id);
            IQueryable <BusinessUnitDTO> dto = BusinessUnitDTO.buildList(bu);

            if (!bu.Any())
            {
                return(NotFound());
            }

            return(Json(bu));
        }
 public static BusinessUnitViewModel MapFrom(this BusinessUnitDTO dto)
 {
     return(new BusinessUnitViewModel()
     {
         Id = dto.Id,
         Name = dto.Name,
         Address = dto.Address,
         PhoneNumber = dto.PhoneNumber,
         Email = dto.Email,
         Information = dto.Information,
         CategoryName = dto.CategoryName,
         TownName = dto.BusinessUnitTownName,
         Picture = dto.Picture,
         Likes = dto.Likes
     });
 }