Exemple #1
0
        public ActionResult DeleteResearch(int id)
        {
            Researcher reseacher = null;
            string     userId    = "";

            userId = User.Identity.GetUserId();
            if (userId == "")
            {
                return(RedirectToAction("Index"));
            }
            using (ResearchDbContext rdbc = new ResearchDbContext())
            {
                reseacher = rdbc.Researchers.Include("Researches").FirstOrDefault(x => x.UserId == userId);
                rdbc.Researchs.Remove(rdbc.Researchs.FirstOrDefault(x => x.Id == id));
                reseacher.DeleteResearch(id);
                rdbc.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }