public ActionResult ServicePage(ServicePageViewModel model, long id) { try { var service = _servicesManager.GetById(id); model = Mapper.Map <Services, ServicePageViewModel>(service); model.IdUserInSystem = Convert.ToInt64(Session["UserId"]); List <PhotoViewModel> photos = new List <PhotoViewModel>(); IQueryable <ServicePhoto> photosList; photosList = _servicePhotoManager.GetServicePhotosByServiceId(service.id).OrderByDescending(x => x.photo.date); foreach (var photo in photosList) { photos.Add(Mapper.Map <ServicePhoto, PhotoViewModel>(photo)); } model.Photos = photos; var commentsService = _commentManager.GetCommentsByServiceId(service.id).OrderByDescending(x => x.dateOfComment); List <CommentViewModel> comments = new List <CommentViewModel>(); foreach (var comment in commentsService) { comments.Add(Mapper.Map <Comments, CommentViewModel>(comment)); } model.Comments = comments; return(View(model)); } catch (Exception) { return(View(model)); } }
public ServicePage(int id) { vm = new ServicePageViewModel(id); BindingContext = vm; InitializeComponent(); webView.Navigating += (s, e) => { if (e.Url.StartsWith("file:")) { try { Regex ex = new Regex(@"\/[a-z0-9]+"); var result = Regex.Matches(e.Url, @"(\/[a-z0-9]+)"); string extractedText = ""; foreach (var item in result) { extractedText += item.ToString(); } var uri = new Uri("https://www.aims.org.au" + extractedText); Device.OpenUri(uri); } catch (Exception ex) { Log.Error("myapp", ex.ToString()); } } else if (e.Url.StartsWith("mailto:")) { try { var uri = new Uri(e.Url); Device.OpenUri(uri); } catch (Exception ex) { Log.Error("myapp", ex.ToString()); } } else if (e.Url.StartsWith("http")) { try { var uri = new Uri(e.Url); Device.OpenUri(uri); } catch (Exception ex) { Log.Error("myapp", ex.ToString()); } } e.Cancel = true; }; }
public ActionResult AddComment(ServicePageViewModel model) { if (model.NewComment == null) { return(RedirectToRoute("ServicePage", new { id = model.Id })); } var entity = Mapper.Map <ServicePageViewModel, Comments>(model); _commentManager.Add(entity); return(RedirectToRoute("ServicePage", new { id = model.Id })); }
public ActionResult NewRating(ServicePageViewModel model) { try { var service = _servicesManager.GetById(model.Id); service.rating = (short)((service.rating + model.NewRating) / 2); _servicesManager.Update(service); return(RedirectToRoute("ServicePage", new { id = model.Id })); } catch (Exception) { return(RedirectToRoute("ServicePage", new { id = model.Id })); } }
public ActionResult NewOrder(ServicePageViewModel model) { try { var service = _servicesManager.GetById(model.Id); model.Price = service.price; var entity = Mapper.Map <ServicePageViewModel, Order>(model); _orderManager.Add(entity); return(RedirectToRoute("UserPage")); } catch (Exception) { return(RedirectToRoute("ServicePage", new { id = model.Id })); } }
public ActionResult AddPhotoService(ServicePageViewModel model, HttpPostedFileBase upload) { try { var pic = new AddPhotos(); var pathPic = pic.AddImage(upload, Server.MapPath("/images/Services/"), "/images/Services/"); var entity = new ServicePhoto() { id_service = model.Id, photo = new Photo() { name = pathPic, date = DateTime.Now, } }; _servicePhotoManager.Add(entity); return(RedirectToRoute("ServicePage", new { id = model.Id })); } catch (Exception) { return(RedirectToRoute("ServicePage", new { id = model.Id })); } }
public IActionResult Index() { var contentServiceEntity = this.InstanceRepository.ContentServiceRepository.GetAll() .Include(x => x.ContentServicePartitions) .OrderBy(x => x.Language == this.SiteLanguage ? 0 : 1).FirstOrDefault(); var viewmodel = new ServicePageViewModel(); var services = this.InstanceRepository.ServiceRepository.GetAll() .Include(x => x.ServiceLanguages) .OrderBy(x => x.Priority).ToList(); viewmodel.Services = services.Select(s => { var sm = Mapper.ToModel(s); if (sm != null) { sm.ServiceLanguages = s?.ServiceLanguages?.Select(Mapper.ToModel).ToList(); } return(sm); }).ToList(); viewmodel.ContentService = Mapper.ToModel(contentServiceEntity); viewmodel.ContentService.ContentServicePartitions = contentServiceEntity?.ContentServicePartitions?.Select(Mapper.ToModel).ToList(); ViewBag.Tab = "services"; return(View(viewmodel)); }