public ActionResult AddSupportingWork(Guid id, SupportingWorkModel model) { var experience = RepositoryFactory.ExperienceRepository.Queryable.SingleOrDefault( x => x.Id == id && x.Creator.Identifier == CurrentUser.Identity.Name); if (experience == null) { return(new HttpNotFoundResult("Could not find the requested experience")); } var work = new SupportingWork { Experience = experience, Description = model.Description, Notes = model.Notes, Type = model.Type }; if (string.IsNullOrWhiteSpace(model.Url)) { if (model.WorkFile != null) { work.Name = model.WorkFile.FileName; work.ContentId = _fileService.Save(model.WorkFile).Id; work.ContentType = model.WorkFile.ContentType; } } else { work.Url = model.Url; } experience.AddSupportingWork(work); RepositoryFactory.ExperienceRepository.EnsurePersistent(experience); return(RedirectToAction("ViewExperience", "Student", new { id })); }
public ActionResult AddSupportingWork(Guid id, SupportingWorkModel model) { var experience = RepositoryFactory.ExperienceRepository.Queryable.SingleOrDefault( x => x.Id == id && x.Creator.Identifier == CurrentUser.Identity.Name); if (experience == null) { return new HttpNotFoundResult("Could not find the requested experience"); } var work = new SupportingWork { Experience = experience, Description = model.Description, Notes = model.Notes, Type = model.Type }; if (string.IsNullOrWhiteSpace(model.Url)) { if (model.WorkFile != null) { work.Name = model.WorkFile.FileName; work.ContentId = _fileService.Save(model.WorkFile).Id; work.ContentType = model.WorkFile.ContentType; } } else { work.Url = model.Url; } experience.AddSupportingWork(work); RepositoryFactory.ExperienceRepository.EnsurePersistent(experience); return RedirectToAction("ViewExperience", "Student", new {id}); }