Exemplo n.º 1
0
        // GET: Survey/Delete/5
        public ActionResult Delete(long empid, long manid, DateTime date)
        {
            //try {
            Survey sur = surveyservice.Get(s => s.date == date && s.employeId == empid && s.managerId == manid);
            List <SurveyQuestion> surquests1 = new List <SurveyQuestion>();

            foreach (var surquest in sur.SurveyQuestions)
            {
                surquests1.Add(new SurveyQuestion
                {
                    id   = surquest.id,
                    date = surquest.date,
                    //employe = surv.employe,
                    employeId = surquest.employeId,
                    //manager = surv.manager,
                    managerId = surquest.managerId,
                    // SurveyQuestions = surv.SurveyQuestions
                });
            }
            surquestservice.Commit();
            surveyservice.Delete(sur);
            foreach (var question in surquests1)
            {
                SurveyQuestion qs = surquestservice.Get(s => s.id == question.id);
                surquestservice.Delete(qs);
                surquestservice.Commit();
            }

            surveyservice.Delete(sur);


            surveyservice.Commit();

            return(RedirectToAction("Index"));

            /* }
             *    catch (Exception e)
             *   {
             *       ModelState.AddModelError("", e.Message);
             *       return View();
             *   }*/
        }