public ActionResult AddService(AddServiceViewModel model, HttpPostedFileBase upload) { try { var pic = new AddPhotos(); var pathPic = pic.AddImage(upload, Server.MapPath("/images/Services/"), "/images/Services/"); var entity = Mapper.Map <AddServiceViewModel, Services>(model); entity.servicePhoto = new List <ServicePhoto>() { new ServicePhoto { photo = new Photo { name = pathPic, date = DateTime.Now } } }; _servicesManager.Add(entity); return(RedirectToRoute("UserPage")); } catch (Exception) { return(View()); } }