public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            try
            {
                var servicePlaceViewModel = new ServicePlaceViewModel();
                var servicePlace          = await _context.ServicePlaces
                                            .Include(s => s.LayoutImage)
                                            .Include(s => s.Service)
                                            .AsNoTracking()
                                            .FirstOrDefaultAsync(m => m.Id == id);

                servicePlaceViewModel          = Mapper.Map(servicePlace, servicePlaceViewModel);
                servicePlaceViewModel.ImageSVG = Encoding.UTF8.GetString(servicePlace.LayoutImage.Content, 0, servicePlace.LayoutImage.Content.Length);
                if (servicePlace == null)
                {
                    return(NotFound());
                }
                return(View(servicePlaceViewModel));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message, CommonC.ErrorLoad);
                TempData["ErrorMessage"] = CommonC.ErrorLoad;
            }
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Create(ServicePlaceViewModel servicePlaceViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var servicePlace = Mapper.Map <ServicePlaceViewModel, ServicePlace>(servicePlaceViewModel);
                    servicePlace.Id     = Guid.NewGuid();
                    servicePlace.UserId = GetCurrentUserId();

                    if (servicePlaceViewModel.LayoutImage == null || !Path.GetExtension(servicePlaceViewModel.LayoutImage.FileName).Equals(".svg"))
                    {
                        ViewData["ServiceId"] = new SelectList(_context.Services.Where(x => x.UserId == GetCurrentUserId()), "Id", "Name", servicePlaceViewModel.ServiceId);
                        ModelState.AddModelError(nameof(servicePlaceViewModel.LayoutImage), "Nem megfelelő képet töltött fel!");
                        return(View());
                    }

                    var image = new Image
                    {
                        Id        = Guid.NewGuid(),
                        Extension = System.IO.Path.GetExtension(servicePlaceViewModel.LayoutImage.FileName),
                        Name      = servicePlaceViewModel.LayoutImage.FileName
                    };
                    servicePlace.LayoutImageId = image.Id;

                    using (var transaction = _context.Database.BeginTransaction())
                    {
                        _context.Add(image);
                        image.Content = ProcessLayoutImage(servicePlaceViewModel.LayoutImage.OpenReadStream(), servicePlace.Id);
                        _context.Add(servicePlace);
                        await _context.SaveChangesAsync();

                        transaction.Commit();
                    }

                    return(RedirectToAction(nameof(Index)));
                }
                catch (Exception e)
                {
                    _logger.LogError(e.Message, CommonC.ErrorCreate);
                    TempData["ErrorMessage"] = CommonC.ErrorCreate;
                }
            }
            return(View(servicePlaceViewModel));
        }
        // GET: WorkingPoint
        public ActionResult Index()
        {
            ServicePlaceViewModel servicePlaceVM = new ServicePlaceViewModel();
            List <WorkingPoint>   workingPoints  = new List <WorkingPoint>();

            workingPoints = vehicleServiceCompanyRepository.GetAllWorkingPoint();
            servicePlaceVM.WorkingPoints = new List <WorkingPointViewModel>();
            if (workingPoints != null)
            {
                foreach (var workingPoint in workingPoints)
                {
                    WorkingPointViewModel workingPointViewModel = new WorkingPointViewModel();
                    workingPointViewModel.ID          = workingPoint.ID;
                    workingPointViewModel.City        = workingPoint.City;
                    workingPointViewModel.Nr          = workingPoint.Nr;
                    workingPointViewModel.Street      = workingPoint.Street;
                    workingPointViewModel.Country     = workingPoint.Country;
                    workingPointViewModel.Reviews     = new List <string>();
                    workingPointViewModel.CompanyName = workingPoint.VehicleServiceCompany.ServiceName;
                    double rate = 0;
                    int    db   = 0;
                    if (workingPoint.Services != null)
                    {
                        foreach (var service in workingPoint.Services)
                        {
                            if (service.Review != null)
                            {
                                workingPointViewModel.Reviews.Add(service.Review.Description);
                                rate += service.Review.Rate;
                                db++;
                            }
                        }
                    }
                    if (db != 0)
                    {
                        rate /= db;
                    }
                    if (rate < 2)
                    {
                        rate = 0;
                    }
                    if (rate >= 2 && rate < 4)
                    {
                        rate = 2;
                    }
                    if (rate >= 4 && rate < 6)
                    {
                        rate = 3;
                    }
                    if (rate >= 6 && rate < 8)
                    {
                        rate = 4;
                    }
                    if (rate >= 8)
                    {
                        rate = 5;
                    }
                    workingPointViewModel.Rate = rate;
                    servicePlaceVM.WorkingPoints.Add(workingPointViewModel);
                }
            }
            return(View(servicePlaceVM));
        }