Badges.Controllers.StudentController.DeleteExperience C# (CSharp) Method

DeleteExperience() public method

public DeleteExperience ( System.Guid id ) : System.Web.Mvc.ActionResult
id System.Guid
return System.Web.Mvc.ActionResult
        public ActionResult DeleteExperience(Guid id)
        {
            var experience = RepositoryFactory.ExperienceRepository.GetNullableById(id);

            if (experience == null)
            {
                return new HttpNotFoundResult("Could not find the requested experience");
            }
            experience.ExperienceOutcomes.Clear();
            var fulfillments = RepositoryFactory.BadgeFulfillmentRepository.Queryable.Where(x => x.Experience.Id.Equals(experience.Id));
            foreach (var fulfillment in fulfillments) {
                fulfillment.Experience = null;
                RepositoryFactory.BadgeFulfillmentRepository.EnsurePersistent(fulfillment);
            }
            RepositoryFactory.ExperienceRepository.EnsurePersistent(experience);
            RepositoryFactory.ExperienceRepository.Remove(experience);
            return RedirectToAction("Portfolio", "Student");
        }