public ActionResult Index(int studentId, string cameFromTitle, bool showRawScale = false, int summaryCount = 0, int detailCount = 0)
        {
            try
            {
                base.SetNavigationLinksUrl();

                ModelServices modelServices = new ModelServices();
                StudentHistoryModel data = new StudentHistoryModel();

                ViewBag.StudentId = studentId;
                ViewBag.ShowRawScale = showRawScale;
                ViewBag.Count = detailCount + 1;
                ViewBag.SummaryCount = summaryCount + 1;
                SiteUser su = ((SiteUser)Session["SiteUser"]);                
                data.History = modelServices.GetStudentHistoryReport(studentId, showRawScale, su.Districts.First().Id);

                tblStudent tempStudent = modelServices.GetStudentById(studentId);
                data.CameFromTitle = cameFromTitle;
                data.Student = tempStudent.FirstName + " " + tempStudent.LastName;
                data.District = modelServices.GetDistrictName(int.Parse(tempStudent.DistrictId.ToString()));
                data.School = modelServices.GetSchoolNameByStudentId(studentId);
                return View("Index", data);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        public ActionResult Index()
        {
            try
            {
                if (User.Identity.IsAuthenticated)
                {
                    // Refresh the session object
                    var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
                    HelperService.SetSiteUserProfile(userManager.FindByName(User.Identity.Name), new dbTIREntities());
                }

                if (User.IsInRole("Adminstrator"))
                {
                    Session["UserIsAdmin"] = true;
                    //return list of teacher in my scope
                    return View();
                }
                else
                { Session["UserIsAdmin"] = false; }
                return View();
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        public ActionResult UpdateGrid(int hiddenYearFilter)
        {
            try
            {
                SiteUser su = ((SiteUser)Session["SiteUser"]);
                ModelServices modelServices = new ModelServices();

                WeightingModel data = new WeightingModel();
                int userAssignedDistrict = su.Districts[0].Id;
                data.DistrictName = modelServices.GetDistrictName(userAssignedDistrict);
                data.SchoolYear = modelServices.SchoolYearDescriptionByYearId(hiddenYearFilter);

                data.DropDown = new DropDownData();
                data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData());
                data.DropDown.Year.SelectedYear = hiddenYearFilter;

                data.SummaryList = modelServices.GetWeightingSummary(userAssignedDistrict, hiddenYearFilter); ;

                return View("Index", data);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        //
        // GET: /AssessmentClassScore/
        public ActionResult Search(AssessmentClassScoreViewModel model)
        {
            try
            {
                db = new dbTIREntities();
                siteUser = ((SiteUser)Session["SiteUser"]);
                assessmentClassScoreService = new AssessmentClassScoreService(siteUser, db);

                if (assessmentClassScoreService.IsAssessmentWeightingExists(model))
                {
                    InitializeAssessmentScoreMetadata(model);
                    if (model.ScoresDetails.Count == 0)
                    {
                        ViewBag.Message = "No Record Found.";
                    }
                }
                else
                {
                    ViewBag.Message = "This combination of subject and assessment does not exist in the system for the selected school year.";
                }
                FillDropDowns(model, true);
                return View("Index", model);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
 public ActionResult Edit(int studentId, string schoolYear, string schoolTerm, string assessmentType, string assessmentDesc, string localId, string subject)
 {
     try
     {
         if (TempData["AssessmentModel"] != null)
         {
             TempData["AssessmentModel"] = TempData["AssessmentModel"];
         }
         dbTIREntities db = new dbTIREntities();
         SiteUser siteUser = ((SiteUser)Session["SiteUser"]);
         assScoreService = new AssessmentScoreService(siteUser, db);
         List<StudentScore> studentScores = assScoreService.GetStudentAssessmentScore(studentId, schoolYear, schoolTerm, assessmentType, assessmentDesc, localId, subject);
         StudentScore score = studentScores.FirstOrDefault();
         //StudentExt studentExt = studentService.GetStudentDetail(studentId, schoolYear);
         //PopulateViewData(studentExt);
         // ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT");
         return View(score);
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
 }
 public ActionResult SaveAssessmentClassScore(List<AssessmentClassScore> model)
 {
     try
     {
         db = new dbTIREntities();
         SiteUser su = ((SiteUser)Session["SiteUser"]);
         assessmentClassScoreService = new AssessmentClassScoreService(su, db);
         string result = assessmentClassScoreService.SaveClassAssessmentScore(model);
         return Json(result, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
 }
 public ActionResult Index()
 {
     try
     {
         var db = new dbTIREntities();
         SiteUser su = (SiteUser)Session["SiteUser"];
         KnowledgeBaseService kbService = new KnowledgeBaseService(su, db);
         List<KnowledgeBase> KnowledgeBaseItems = new List<KnowledgeBase>();
         KnowledgeBaseItems = kbService.GetKnowledgeBase().ToList();
         ViewBag.AllowEdit = HelperService.AllowUiEdits(su.RoleDesc, "USER");
         return View(KnowledgeBaseItems);
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
 }
        public ActionResult KnowledgeBaseDetail(int KnowledgeBaseId)
        {
            try
            {
                var db = new dbTIREntities();
                SiteUser su = (SiteUser)Session["SiteUser"];
                KnowledgeBaseService kbService = new KnowledgeBaseService(su, db);
                int DistrictId = su.Districts[0].Id;
                var listdata = kbService.GetKnowledgeBaseDetail(KnowledgeBaseId, DistrictId);
                return View(listdata);

            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        public ActionResult GetAnnouncements()
        {
            try
            {
                var db = new dbTIREntities();
                SiteUser su = (SiteUser)Session["SiteUser"];
                SupportService supportService = new SupportService(su, db);

                return PartialView("_AnnouncementPartial", new SiteModels() 
                { 
                    Announcements = supportService.GetAnnouncements().ToList() 
                }); 
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        public ActionResult Announcements(int? page)
        {
            try
            {
                int pageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]);
                int pageNumber = (page ?? 1);
                var db = new dbTIREntities();
                SiteUser su = (SiteUser)Session["SiteUser"];
                SupportService supportService = new SupportService(su, db);   
                var listData = (supportService.GetAnnouncements()).ToPagedList(pageNumber, pageSize);
                return View("Announcements", listData);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }

        }
 public ActionResult AssessmentDetail(TIRDetailReportParameter detailReportParameter)
 {
     try
     {
         HeirarchicalTIRDetailModel model = new HeirarchicalTIRDetailModel();
         InitializeReportMetadata(model, detailReportParameter);
         model.ReportType = detailReportParameter.AssessmentTypeDesc;
         model.ReportTemplateId = detailReportParameter.ReportTemplateId;
         ViewBag.ShowPercentile = detailReportParameter.ReportTemplateId != EDS.Constants.SystemParameter.ReportTemplateType.FandPType;
         ViewBag.ShowGrowth = detailReportParameter.ReportTemplateId == EDS.Constants.SystemParameter.ReportTemplateType.FandPType;
         return View("HeirarchicalTIRDetail", model);
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
 }
        public ActionResult SummaryReportById(int teacherId, bool viewMeetExceedSummary = true)
        {
            try
            {
                SetNavigationLinksUrl();
                SetViewBag(viewMeetExceedSummary);
                ViewBag.SummaryLink = "SummaryReportById";
                ViewBag.TeacherFilter = teacherId;
                bool unAuthorizedRequest = false;
                SiteUser su = ((SiteUser)Session["SiteUser"]);
                ModelServices modelServices = new ModelServices();
                StudentService studentService = new StudentService(su, entities);
                int defaultDistrict = su.Districts[0].Id;
                int schoolYearId = modelServices.SchoolYearId();
                int[] userSchools = modelServices.getSchoolsByUserId(su.EdsUserId).ToArray();

                var dropdownTeachers = modelServices.TeacherDropDownDataBySchoolAndYear(userSchools, schoolYearId, defaultDistrict);
                unAuthorizedRequest = dropdownTeachers.Where(x => x.Id == teacherId).Count() == 0 ? true : false;

                if (unAuthorizedRequest)
                {
                    return RedirectToAction("AccessDenied", "Error");
                }

                TIRSummaryModel data = new TIRSummaryModel();
                data.SchoolYear = modelServices.SchoolYearDescription();
                data.DropDown = new DropDownData();
                data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData());
                data.DropDown.Year.SelectedYear = schoolYearId;
                data.DropDown.District = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId));
                data.DropDown.Teacher = new TeacherDropDown(dropdownTeachers);
                data.DropDown.Teacher.SelectedTeacher = teacherId;
                data.DropDown.Race = new RaceDropDown(modelServices.DropDownDataForRace(), true);
                data.DropDown.Gender = new GenderDropDown(modelServices.DropDownDataForGender(), true);
                data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, new[] { teacherId }));

                var filterParameter = new FilterParameter
                {
                    ClassId = classDefaultValue,
                    Teacher = teacherId,
                    School = userSchools.First(),
                    Year = schoolYearId,
                    SchoolYear = data.SchoolYear
                };
                data.SummaryList = modelServices.GetSummaryReport(filterParameter);
                data.DropDown.School = new SchoolDropDown(modelServices.GetSchoolDropDownData(su.EdsUserId, schoolYearId));
                var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su);
                ViewBag.ReportFilters = reportFilterViewModel;
                return View("SummaryReport", data);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        public ActionResult SummaryReport(bool viewMeetExceedSummary = true)
        {
            try
            {
                SetNavigationLinksUrl();
                ViewBag.SummaryLink = "SummaryReport";

                SetViewBag(viewMeetExceedSummary);
                SiteUser su = ((SiteUser)Session["SiteUser"]);
                ModelServices modelServices = new ModelServices();
                StudentService studentService = new StudentService(su, entities);

                int defaultDistrict = su.Districts[0].Id;
                int schoolYearId = modelServices.SchoolYearId();
                int[] userSchools = modelServices.getSchoolsByUserId(su.EdsUserId).ToArray();

               

                TIRSummaryModel data = new TIRSummaryModel();
                data.SchoolYear = modelServices.SchoolYearDescription();
                data.DropDown = new DropDownData();
                data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData());
                data.DropDown.Year.SelectedYear = schoolYearId;
                data.DropDown.District = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId));

                data.DropDown.Race = new RaceDropDown(modelServices.DropDownDataForRace(), true);
                data.DropDown.Race.SelectedRace = -1;
                data.DropDown.Gender = new GenderDropDown(modelServices.DropDownDataForGender(), true);
                data.DropDown.Gender.SelectedGender = -1;

                data.DropDown.School = new SchoolDropDown(modelServices.GetSchoolDropDownData(su.EdsUserId, schoolYearId));
                if (su.isTeacher)
                {
                    data.DropDown.Teacher = new TeacherDropDown(
                        new List<DropDownIdName>() { new DropDownIdName() { Id = su.EdsUserId, Name = su.UserFullName } });
                    data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, new[] { su.EdsUserId }));
                }
                else // data administrator and eds administrator
                {
                    int[] schoolsTeacher = modelServices.getTeachersBySchoolsId(userSchools).ToArray();
                    data.DropDown.Teacher = new TeacherDropDown(modelServices.TeacherDropDownDataBySchoolAndYear(userSchools, schoolYearId, defaultDistrict));
                    data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, schoolsTeacher));
                }

                var filterParameter = new FilterParameter
                {
                    ClassId = classDefaultValue,
                    Teacher = su.EdsUserId,
                    School = userSchools.First(),
                    Year = schoolYearId,
                    SchoolYear = data.SchoolYear
                };
                data.SummaryList = modelServices.GetSummaryReport(filterParameter);
                var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su);
                ViewBag.ReportFilters = reportFilterViewModel;
                return View(data);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        public ActionResult UpdateGrid(FilterParameter filterParameter)
        {
            try
            {
                SetNavigationLinksUrl();
                SetViewBag(filterParameter.ViewMeetExceedSummary);
                ViewBag.SummaryLink = "UpdateGrid";
                bool unAuthorizedRequest = false;
                SiteUser su = ((SiteUser)Session["SiteUser"]);
                ModelServices modelServices = new ModelServices();
                TIRSummaryModel data = new TIRSummaryModel();

                int defaultDistrict = su.Districts[0].Id;
                data.DropDown = new DropDownData();
                ViewBag.FilterParameter = filterParameter;

                #region Initializations                
                var dropdownSchools = modelServices.GetSchoolDropDownData(su.EdsUserId, filterParameter.Year);
                var schoolCount = dropdownSchools.Where(x => x.Id == filterParameter.School).Count();
                unAuthorizedRequest = schoolCount == 0 ? true : false;
                if (unAuthorizedRequest)
                {
                    return RedirectToAction("AccessDenied", "Error");
                }

                if (!unAuthorizedRequest)
                {
                    if (su.isTeacher)
                    {
                        unAuthorizedRequest = (su.EdsUserId != filterParameter.Teacher) ? true : false;
                        if (!unAuthorizedRequest)
                            data.DropDown.Teacher = new TeacherDropDown(new List<DropDownIdName>() { new DropDownIdName() { Id = su.EdsUserId, Name = su.UserFullName } });
                    }
                    else
                    {
                        var dropdownTeachers = modelServices.TeacherDropDownDataBySchoolAndYear(new int[] { filterParameter.School }, filterParameter.Year, defaultDistrict);
                        unAuthorizedRequest = dropdownTeachers.Where(x => x.Id == filterParameter.Teacher).Count() == 0 ? true : false;

                        if (!unAuthorizedRequest)
                        {
                            data.DropDown.Teacher = new TeacherDropDown(dropdownTeachers);
                            data.DropDown.Teacher.SelectedTeacher = filterParameter.Teacher;
                        }
                    }
                }
                #endregion
                   
                //TODO: need to refactor below code if possible.
                ViewBag.TeacherFilter = filterParameter.Teacher;
                ViewBag.SchoolFilter = filterParameter.School;
                ViewBag.YearFilter = filterParameter.Year;
                ViewBag.ClassFilter = filterParameter.ClassId;
                ViewBag.Race = filterParameter.Race;
                ViewBag.Gender = filterParameter.Gender;
                ViewBag.FrlIndicator = filterParameter.FrlIndicator;
                ViewBag.IEPIndicator = filterParameter.IEPIndicator;
                ViewBag.LEPIndicator = filterParameter.LEPIndicator;
                ViewBag.Hispanic = filterParameter.Hispanic;


                #region Init Filter Parameters
                data.SchoolYear = modelServices.SchoolYearDescriptionByYearId(filterParameter.Year);
                data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData());
                data.DropDown.Year.SelectedYear = filterParameter.Year;
                data.DropDown.District = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId));
                data.DropDown.School = new SchoolDropDown(dropdownSchools);
                data.DropDown.School.SelectedSchool = filterParameter.School;
                data.SummaryList = modelServices.GetSummaryReport(filterParameter);
             
                data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(filterParameter.Year, new[] { filterParameter.Teacher }));

                data.DropDown.Race = new RaceDropDown(modelServices.DropDownDataForRace(), true);
                data.DropDown.Race.SelectedRace = filterParameter.Race;
                data.DropDown.Gender = new GenderDropDown(modelServices.DropDownDataForGender(), true);
                data.DropDown.Gender.SelectedGender = filterParameter.Gender;
                data.Hispanic = filterParameter.Hispanic;
                data.IepIndicator = filterParameter.IEPIndicator;
                data.LepIndicator = filterParameter.LEPIndicator;
                data.FrlIndicator = filterParameter.FrlIndicator;

                data.DropDown.SchoolClass.SelectedClass = filterParameter.ClassId;
                #endregion

                filterParameter.SchoolYear = data.SchoolYear;
                var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su);
                ViewBag.ReportFilters = reportFilterViewModel;
                return View("SummaryReport", data);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
 public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var user = await UserManager.FindAsync(model.UserName, model.Password);
             if (user != null)
             {
                 
                 if (HelperService.IsUserAuthorized(user, new dbTIREntities()))
                 {
                     await SignInAsync(user, model.RememberMe);
                     // Place user's profile object into session.
                     SiteUser siteUser = HelperService.SetSiteUserProfile(user, new dbTIREntities());
                     // Record user last logged in info.
                     HelperService.SetUserLoginInfo(siteUser, new dbTIREntities());
                     // Let user in!
                     return RedirectToLocal(returnUrl);
                 }
                 else
                 {
                     ModelState.AddModelError("", "This account is not authorized for the current school year. Please contact your administrator or EDS support if this is incorrect.");
                 }
             }
             else
             {
                 ModelState.AddModelError("", "Invalid username or password.");
             }
         }
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
     // If we got this far, something failed, redisplay form
     return View(model);
 }
 public ActionResult ResetPasswordConfirmation(string token, string id)
 {
     //if (WebSecurity.ResetPassword(model.Token, model.NewPassword))
     //{
     //    return RedirectToAction("PasswordResetSuccess");
     //}
     ModelServices modelServices = new ModelServices();
     try
     {
         if (modelServices.IsResetTokenValid(token, id))
         {
             ResetPasswordConfirmModel data = new ResetPasswordConfirmModel() { Token = token };
             return View(data);
         }
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
     return RedirectToAction("PasswordResetFailure");
 }
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            try
            {
                ModelServices services = new ModelServices();
                string email = services.GetEmailByUserId(model.UserName);
                if (email != string.Empty && email != null)
                {
                    string token = services.GeneratePasswordResetToken(model.UserName, email);
                    if (ConfigurationManager.AppSettings["systemMode"].ToString() == "debug")
                    {
                        services.EmailPasswordReset(@"*****@*****.**", token, services.GetUserIdByUserName(model.UserName));
                    }
                    else
                    {
                        services.EmailPasswordReset(email, token, services.GetUserIdByUserName(model.UserName));
                    }

                    return RedirectToAction("ResetPwStepTwo");
                }
                else
                {
                    ModelState.AddModelError("UserName", "Username not found");
                    return View();
                }
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
            //return RedirectToAction("InvalidUserName");
        }
        public ActionResult Edit(
            [Bind(
                Include =
                    "Subject,LocalId,StudentId,FirstName,LastName,Score,AssessmentType,SchoolTerm,SchoolYear,AssessmentDesc,AssessmentId"
                )] StudentScore studentScore)
        {
            try
            {
                dbTIREntities db = new dbTIREntities();
                SiteUser siteUser = ((SiteUser)Session["SiteUser"]);
                AssessmentScoreService assessmentService = new AssessmentScoreService(siteUser, db);
                ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT");

                tblAssessmentScore assscore =
                    db.tblAssessmentScores.Where(
                        k => k.AssessmentId == studentScore.AssessmentId && k.StudentId == studentScore.StudentId)
                        .ToList()
                        .FirstOrDefault();
                assscore.Score = studentScore.Score;

                assessmentService.UpdateStudentScore(assscore);
                return RedirectToAction("Search", TempData["AssessmentModel"]);
                //  return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }

        }
        public ActionResult ViewAttachment(string physicalFileName, string fileExtension)
        {
            try
            {
                physicalFileName = physicalFileName + "" + fileExtension;
                return File(DocumentManagementService.GetFile(physicalFileName), MediaTypeNames.Application.Octet, physicalFileName);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }

        }
 public ActionResult AccessDenied()
 {
     Logging log = new Logging();
     log.LogException(new UnauthorizedAccessException());
     return View("AccessDenied");
 }
        public ActionResult CreateKnowledgeBaseItem(KnowledgeBase model)
        {
            try
            {
                SiteUser siteUser = (SiteUser)Session["SiteUser"];
                ModelServices modelService = new ModelServices();
                List<HttpPostedFileBase> httpPostedFileBases = null;
                if (model.Files.ToList()[0] != null)
                {
                    httpPostedFileBases = model.Files.ToList();
                    var allowedFileSize = ConfigurationManager.AppSettings["FileSize"].ToString();
                    if (!DocumentManagementService.ValidateAttachmentSize(httpPostedFileBases))
                    {
                        ModelState.AddModelError("Files", "Attachment Size exceeds allowed limit of " + allowedFileSize + " MB");
                    }
                }

                if (ModelState.IsValid)
                {
                    var db = new dbTIREntities();
                    KnowledgeBaseService kbService = new KnowledgeBaseService(siteUser, db);

                    if (!kbService.IsKnowledgeBaseExists(model.Title))
                    {
                        //TODO: Till nowwe are picking first district Id. Need to refactor code when a user belongs to more than 1 district.
                        model.DistrictId = siteUser.Districts[0].Id;
                        model.RoleId = model.RoleId;
                        model.CreatedDateTime = DateTime.Now;
                        model.CreatedUserId = siteUser.EdsUserId;
                        model.FileDetails = model.Files.ToList()[0] != null ? DocumentManagementService.GetFileDetail(model.Files) : null;
                        kbService.SaveKnowledgeBase(model);
                        return RedirectToAction("Index");
                    }
                    else
                    {
                        ModelState.AddModelError("Title", "Duplicate Title - please choose a unique title.");
                    }
                }
                ViewBag.RoleId = new SelectList(modelService.GetRolesForRole((int)(siteUser.Role)), "RoleId", "RoleDesc");
                return View();
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        public ActionResult Create(WeightingViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db = new dbTIREntities();
                    siteUser = ((SiteUser)Session["SiteUser"]);
                    commonService = new CommonService(siteUser, db);
                    weightingService = new WeightingService(siteUser, db);
                    bool weightingAlreadyExist = weightingService.SaveWeightingDetail(model);
                    if (!weightingAlreadyExist)
                    {
                        ViewBag.UserMessage = "Data Saved Successfully.";
                        model = new WeightingViewModel();
                        FillDropDowns(model);
                        ModelState.Clear();

                    }
                    else
                    {
                        ViewBag.UserMessage = "Data already exists.";
                        FillDropDowns(model);
                    }

                }
                catch (Exception ex)
                {
                    Logging log = new Logging();
                    log.LogException(ex);
                    return View("GeneralError");
                }
            }
            return View(model);
        }
        public ActionResult ResetPasswordConfirmation(ResetPasswordConfirmModel model)
        {
            ModelServices modelServices = new ModelServices();
            try
            {
                string aspId = modelServices.GetAspUserIdForToken(model.Token);

                UserManager.RemovePassword(aspId);
                UserManager.AddPassword(aspId, model.NewPassword);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
            return RedirectToAction("PasswordResetComplete");
        }