public ConfigurationItem(Configuration config, AssessmentEntities context)
        {
            C__id             = config.C__id;
            Id                = config.Id;
            PartNo            = config.PartNo;
            Description       = config.Description;
            Revision          = config.Revision;
            FilePath          = config.FilePath;
            ConfigurationName = config.ConfigurationName;
            BomPartNumber     = config.BomPartNumber;
            IsActive          = config.IsActive;
            IsRoot            = config.IsRoot;
            Preview           = config.Preview;
            Quantity          = 1;

            ChildConfigurations = new ObservableCollection <ConfigurationItem>();

            var bomChildEntries = context.Boms.Where(x => x.ParentConfigIndex == config.Id);

            foreach (var entry in bomChildEntries)
            {
                ChildConfigurations.Add(
                    new ConfigurationItem(
                        context.Configurations.Where(x => x.Id == entry.ChildConfigIndex).First(), context
                        )
                {
                    Quantity = entry.Qty
                });
            }
        }
        public ActionResult UserDashBoard([Bind(Include = "objTweet,objTweetList,objFollow")] TweetViewModel objTwt)
        {
            AssessmentEntities db    = new AssessmentEntities();
            tweet          objTweet  = new tweet();
            following      objFollow = new following();
            TweetViewModel oTwt      = new TweetViewModel();

            if (ModelState.IsValid)
            {
                objTweet.user_id = Session["UserID"].ToString();
                objTweet.created = DateTime.Now;
                objTweet.message = objTwt.objTweet.message;
                db.tweets.Add(objTweet);
                db.SaveChanges();


                objFollow.user_id      = Session["UserID"].ToString();
                objFollow.following_id = objTwt.objFollow.following_id;
                db.followings.Add(objFollow);
                db.SaveChanges();

                oTwt.objTweetList     = GetTweetList();
                oTwt.objTweet         = new tweet();
                oTwt.objTweet.message = string.Empty;
                oTwt.tweetCount       = oTwt.objTweetList.Count.ToString();
                string result = GetFollowingList();
                oTwt.followingCount = result.Split(';')[0];
                oTwt.followersCount = result.Split(';')[1];
                return(View(oTwt));
            }
            return(View(oTwt));
        }
 public RootConfiguration(Configuration config, AssessmentEntities context)
 {
     Id = config.Id;
     ConfigurationName   = config.ConfigurationName;
     ChildConfigurations = new ObservableCollection <ConfigurationItem>();
     ChildConfigurations.Add(new ConfigurationItem(config, context));
 }
        public ActionResult AllData(string param, int? page, string column, string sortOrder)
        {
            using (var context = new AssessmentEntities())
            {
                try
                {
                    IEnumerable<spASSESSMENT_RECORDS_Result> results = null;
                    param = string.IsNullOrEmpty(param) ? "" : param;
                    //sortOrder = string.IsNullOrEmpty(sortOrder) ? "" : sortOrder;
                    ViewBag.Order = "";
                    if (String.IsNullOrEmpty(column) && String.IsNullOrWhiteSpace(sortOrder))
                        results = getAllRecords(context, param).ToList();
                    else
                        results = SortTable(context, param, column, sortOrder).ToList();

                    var pageView = results.ToPagedList(page ?? 1, 5);
                    return View("_AllData", "AllData", pageView);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    ViewBag.ErrorMsg = "Unable to fetch the data due to bad url";
                    return View("Error");
                }
            }
        }
 public ActionResult Create(RUBRICS_DATA rubricData)
 {
     if (ModelState.IsValid)
     {
         using (var context = new AssessmentEntities())
         {
             try
             {
                 context.RUBRICS_DATA.Add(rubricData);
                 context.SaveChanges();
                 ViewBag.InsertionResult = "Rubric Successfully inserted.";
             }
             catch (Exception ex)
             {
                 Response.Write(ex.Message);
                 ViewBag.ErrorMsg = "Performance Indicator already Exist. Please check the input again";
                 return View("Error");
             }
             finally
             {
                 DepartmentList departmentList = new DepartmentList();
                 ViewBag.Departments = departmentList.getDepartmentList(context);
             }
         }
         return PartialView("_InsertResult");
     }
     else
     {
         ViewBag.ErrorMsg = "Invalid Input entered.";
         return View("Error");
     }
 }
 public ActionResult Create()
 {
     using (var context = new AssessmentEntities())
     {
         DepartmentList departmentList = new DepartmentList();
         ViewBag.Departments = departmentList.getDepartmentList(context);
         return View();
     }
 }
 public ActionResult Profiler()
 {
     if (Session["UserID"] != null)
     {
         AssessmentEntities db = new AssessmentEntities();
         var objPerson         = db.people.Find(Session["UserID"].ToString());
         return(View("Profile", objPerson));
     }
     return(RedirectToAction("Login"));
 }
        //Reference: http://highoncoding.com/Articles/770_Implementing_Dynamic_DropDownList_in_ASP_NET_MVC_3_Framework.aspx

        public List<SelectListItem> getDepartmentList(AssessmentEntities context)
        {
            List<SelectListItem> departmentList = new List<SelectListItem>();
            departmentList.Add(new SelectListItem() { Text = "Please select Department", Value = "default" });
            var result = context.DEPARTMENTS.ToList();
            foreach (var item in result)
            {
                departmentList.Add(new SelectListItem() { Text = item.DEPARTMENT_DESC, Value = item.DEPARTMENT_CD });
            }
            return departmentList;
        }
 public List<SelectListItem> getProfessorListList()
 {
     List<SelectListItem> departmentList = new List<SelectListItem>();
     using (var context = new AssessmentEntities())
     {
         //PerformanceIndicator pIndicators = new PerformanceIndicator();
         var result = context.USER_INFO.ToList();
         foreach (var item in result)
         {
             departmentList.Add(new SelectListItem() { Text = item.INSTRUCTOR_NAME, Value = item.INSTRUCTOR_EMAILID });
         }
         return departmentList;
     }
 }
 //Reference: http://highoncoding.com/Articles/770_Implementing_Dynamic_DropDownList_in_ASP_NET_MVC_3_Framework.aspx
 public List<SelectListItem> getPerformanceIndicatorList(string dept)
 {
     List<SelectListItem> performanceIndicators = new List<SelectListItem>();
     using (var context = new AssessmentEntities())
     {
         //var result = context.RUBRICS_DATA.Where(x => x.DEPARTMENT_CD.Equals(id)).Select(x => x.PERFORMANCE_INDICATOR).Distinct().ToList();
         var result = context.spRUBRICGETPERFORMANCEINDICATORS(dept).OrderBy(order=>order.outcomes);
         foreach (var item in result)
         {
             performanceIndicators.Add(new SelectListItem() { Text = item.outcomes +"-" +item.performance_indicator, Value = item.outcomes });
         }
         return performanceIndicators;
     }
 }
 public ActionResult AllRubrics()
 {
     if (ModelState.IsValid)
     {
         using (var context = new AssessmentEntities())
         {
             DepartmentList departmentList = new DepartmentList();
             ViewBag.Departments = departmentList.getDepartmentList(context);
         }
         return View();
     }
     ViewBag.ErrorMsg = "Invalid option selected. No such record exist";
     return View("Error");
 }
        public ActionResult SignUp([Bind(Include = "user_id,passwod,fullname,email")] person person)
        {
            AssessmentEntities db = new AssessmentEntities();

            if (ModelState.IsValid)
            {
                person.active = true;
                person.joined = DateTime.Now;
                db.people.Add(person);
                db.SaveChanges();
                return(RedirectToAction("Login"));
            }

            return(View(person));
        }
 public ActionResult Edit_Save(USER_INFO userinfo)
 {
     using (var context = new AssessmentEntities())
     {
         try
         {
             var i = context.spINSTRUCTOREDIT(userinfo.INSTRUCTOR_EMAILID, userinfo.INSTRUCTOR_NAME);
             return RedirectToAction("AllInstructors");
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
             ViewBag.ErrorMsg = "Unable to edit the record. Please retry again.";
             return View("Error");
         }
     }
 }
 public ActionResult Login(person objUser)
 {
     if (ModelState.IsValid)
     {
         using (AssessmentEntities db = new AssessmentEntities())
         {
             var obj = db.people.Where(a => a.user_id.Equals(objUser.user_id) && a.passwod.Equals(objUser.passwod)).FirstOrDefault();
             if (obj != null)
             {
                 Session["UserID"]   = obj.user_id.ToString();
                 Session["UserName"] = obj.fullname.ToString();
                 return(RedirectToAction("UserDashBoard"));
             }
         }
     }
     return(View(objUser));
 }
 public ActionResult AllInstructors()
 {
     using (var context = new AssessmentEntities())
     {
         try
         {
             var result = (IEnumerable<spINSTRUCTORGETALLRECORDS_Result>)context.spINSTRUCTORGETALLRECORDS().ToList();
             return View(result);
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
             ViewBag.ErrorMsg = "Something went wrong while fetching. Please retry after some time.";
             return View("Error");
         }
     }
 }
 public ActionResult Edit(string email)
 {
     using (var context = new AssessmentEntities())
     {
         try
         {
             var result = context.spINSTRUCTORGETDETAILS(email).SingleOrDefault();
             return View(result);
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
             ViewBag.ErrorMsg = "Unable to fetch the record. Please retry again.";
             return View("Error");
         }
     }
 }
        public ActionResult Delete(string email)
        {
            using (var context = new AssessmentEntities())
            {
                try
                {
                    var result = context.spINSTRUCTORDELETE(email);
                    return RedirectToAction("AllInstructors");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    ViewBag.ErrorMsg = "The Record does not exist or has already been deleted.";
                    return View("Error");
                }

            }
        }
        public List <tweet> GetTweetList()
        {
            List <tweet>       res = new List <tweet>();
            AssessmentEntities db  = new AssessmentEntities();
            var tweets             = db.tweets.ToList();

            if (tweets != null)
            {
                foreach (var item in tweets)
                {
                    if (item.user_id == Session["UserID"].ToString())
                    {
                        res.Add(item);
                    }
                }
            }
            return(res);
        }
        public IQueryable<spASSESSMENT_RECORDS_Result> SortTable(AssessmentEntities context, string param, string column, string sortOrder)
        {
            ViewBag.Order = String.IsNullOrEmpty(sortOrder) ? "desc" : "";
            sortOrder = String.IsNullOrEmpty(sortOrder) ? "" : sortOrder;
            var results = context.spASSESSMENT_RECORDS(param).AsQueryable();
            Func<IQueryable<spASSESSMENT_RECORDS_Result>, Expression<Func<spASSESSMENT_RECORDS_Result, string>>, IOrderedQueryable<spASSESSMENT_RECORDS_Result>> orderBy;

            if (!sortOrder.Equals("desc"))
            {
                orderBy = Queryable.OrderBy;
            }
            else
            {
                orderBy = Queryable.OrderByDescending;
            }
            results = orderBy(results, spASSESSMENT_RECORDS_Result.Order(column))
               .ThenBy(searchResults => searchResults.OUTCOMES);
            return results;
        }
        // GET: Product_Details/Delete/5
        public ActionResult Delete(int?id)
        {
            AssessmentEntities db = new AssessmentEntities();
            tweet oTwt            = db.tweets.Find(id);

            db.tweets.Remove(oTwt);
            db.SaveChanges();
            TweetViewModel oTwts = new TweetViewModel();

            oTwts.objTweetList     = GetTweetList();
            oTwts.objTweet         = new tweet();
            oTwts.objTweet.message = string.Empty;
            oTwts.tweetCount       = oTwts.objTweetList.Count.ToString();
            string result = GetFollowingList();

            oTwts.followingCount = result.Split(';')[0];
            oTwts.followersCount = result.Split(';')[1];
            return(View("UserDashBoard", oTwts));
        }
 public ActionResult ChangePassword(ChangePassword changePassword)
 {
     if (ModelState.IsValid)
     {
         using (var context = new AssessmentEntities())
         {
             var AdminRecord = context.spLOGIN(changePassword.UserName, changePassword.ExistingPassword).SingleOrDefault();
             if (AdminRecord != null)
             {
                 AdminRecord.ADMIN_PASSWORD = changePassword.NewPassword;
                 context.SaveChanges();
                 ModelState.AddModelError("", "Password Changed Successfully");
             }
             else
             {
                 ModelState.AddModelError("", "Please enter correct password");
             }
         }
     }
     return View(changePassword);
 }
        public ActionResult Index(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (var context = new AssessmentEntities())
                {
                    var userExist = context.spLOGIN(model.UserName, model.Password).ToList();
                    if (userExist.Count == 1)
                    {
                        FormsAuthentication.SetAuthCookie(model.UserName, false);
                        return RedirectToAction("Index", "admin");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Log in credentials invalid");
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        public ActionResult Reference()
        {
            ViewBag.total = 0;
            string linkid;
            using (var context = new AssessmentEntities())
            {
                try
                {
                    linkid = Request.QueryString["linkid"].ToString();
                    var VerifyLink = context.ASSESSMENT_LINK.Where(link => link.RANDOM_STRING == linkid).ToList();

                    if (VerifyLink.Count == 1)
                    {
                        var linkDetails = VerifyLink.First();

                        var result = context.spRUBRICGETSEARCHRESULTS(linkDetails.DEPARTMENT_CD, linkDetails.OUTCOMES).ToList();
                        var rubRowID = result.Select(rubrowID => rubrowID.RUBRIC_ROWID.ToString()).ToList();
                        Session["RubRowIDS"] = rubRowID;
                        foreach (var item in rubRowID)
                        {
                            Session[item] = "0-0-0-0";
                        }
                        result.First().Instructor_EmailID = linkDetails.INSTRUCTOR_EMAILID;
                        return View(result);
                    }
                    else
                    {
                        ViewBag.ErrorMsg = "Invalid URL. Please check the Link again";
                        return View("Error");
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMsg = "Unable to fetch data. Please contact the Assessment officer";
                    return View("Error");
                }
            }
        }
        public string GetFollowingList()
        {
            string             res            = string.Empty;
            int                followingCount = 0;
            int                followsCount   = 0;
            AssessmentEntities db             = new AssessmentEntities();
            var                follows        = db.followings.ToList();

            if (follows != null)
            {
                foreach (var item in follows)
                {
                    if (item.user_id == Session["UserID"].ToString())
                    {
                        followingCount++;
                    }
                    if (item.following_id == Session["UserID"].ToString())
                    {
                        followsCount++;
                    }
                }
            }
            return(followingCount + ";" + followsCount);
        }
 public ActionResult Edit(int rubID)
 {
     using (var context = new AssessmentEntities())
     {
         var results = context.RUBRICS_DATA.Where(rubid => rubid.RUBRIC_ROWID == rubID).SingleOrDefault();
         return PartialView("_EditRubric", results);
     }
 }
 public IQueryable<spASSESSMENT_RECORDS_Result> getAllRecords(AssessmentEntities context, string param)
 {
     return context.spASSESSMENT_RECORDS(param).AsQueryable();
 }
 public PartialViewResult getRubricDetails(spRUBRICSGETRECORD_RUBID_Result rubricRecord, AssessmentEntities context)
 {
     var results = context.spRUBRICGETSEARCHRESULTS(rubricRecord.DEPARTMENT_CD, rubricRecord.OUTCOMES).SingleOrDefault();
     return PartialView("_Search", results);
 }
 public ActionResult SaveRubric(RUBRICS_DATA rubricData)
 {
     using (var context = new AssessmentEntities())
     {
         context.spUPDATERUBRICDATA(rubricData.RUBRIC_ROWID, rubricData.OUTCOMES, rubricData.PERFORMANCE_INDICATOR, rubricData.TOPIC, rubricData.POOR, rubricData.DEVELOPING, rubricData.DEVELOPED, rubricData.EXEMPLARY, rubricData.EXPECTATION_LEVEL);
         context.SaveChanges();
         var rubricRecord = context.spRUBRICSGETRECORD_RUBID(rubricData.RUBRIC_ROWID).SingleOrDefault();
         return EditCancel(rubricData.RUBRIC_ROWID);
     }
 }
 private ConfigurationProvider()
 {
     _context = new AssessmentEntities();
 }
        public ActionResult Reference(ASSESSMENT_DATA assessedData)
        {
            bool status = false;
            using (var context = new AssessmentEntities())
            {
                try
                {
                    if (context.ASSESSMENT_DATA.Where(rdmstring => rdmstring.RANDOM_STRING == assessedData.RANDOM_STRING).ToList().Count != 0)
                    {
                        //link is already been used
                        //delete old records
                        context.spASSESSMENT_DELETE_OLD_RECORDS(assessedData.RANDOM_STRING);
                        context.SaveChanges();
                    }

                    foreach (var item in Session["RubRowIDS"] as List<String>)
                    {
                        string sessionData = Session[item].ToString();
                        String[] data = sessionData.Split('-');
                        assessedData.RUBRIC_ROWID = Int16.Parse(item);
                        assessedData.POOR = Int16.Parse(data[0]);
                        assessedData.DEVELOPING = Int16.Parse(data[1]);
                        assessedData.DEVELOPED = Int16.Parse(data[2]);
                        assessedData.EXEMPLARY = Int16.Parse(data[3]);
                        if (assessedData.POOR + assessedData.DEVELOPING + assessedData.DEVELOPED + assessedData.EXEMPLARY != 0)
                        {
                            context.ASSESSMENT_DATA.Add(assessedData);
                            context.SaveChanges();

                            context.spLINK_UPDATESTATUS(assessedData.RANDOM_STRING, false);
                            context.SaveChanges();

                        }
                        else
                        {
                            ViewBag.ErrorMsg = "Please input at least one record for assessment";
                            return View("Error");
                        }
                    }
                    return View("Success");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    ViewBag.ErrorMsg = "Please complete all form fields.";
                    return View("Error");
                }
            }
        }
 public ActionResult Search(FormCollection f)
 {
     using (var context = new AssessmentEntities())
     {
         try
         {
             string Outcomes = f["Outcomes"].ToString();
             string deptSelected = f["DEPARTMENT"].ToString();
             var result = context.spRUBRICGETSEARCHRESULTS(deptSelected, Outcomes).ToList();
             //saving variables for emailing
             Session["Outcome"] = Outcomes;
             Session["DEPARTMENT"] = deptSelected;
             return PartialView("_Search", result);
         }
         catch (Exception ex)
         {
             Response.Write(ex.Message);
             ViewBag.ErrorMsg = "Bad selection. No such rubric exist.";
             return View("Error");
         }
     }
 }
        public ActionResult Send(FormCollection f)
        {
            using (var context = new AssessmentEntities())
            {

                string department = Session["DEPARTMENT"].ToString();
                string outcome = Session["Outcome"].ToString();
                string instructorSelected = f["InstructorList"].ToString();
                string urlParameters = "Dept=" + department + "&outcome=" + outcome + "&inst=" + instructorSelected;
                string rdm_string = RandomString(30);
                context.spLINK_INSERT(rdm_string, outcome, department, instructorSelected, true);
                context.SaveChanges();
                string finalLink = link + rdm_string;
                SendMail sendmail = new SendMail();
                if (sendmail.SendEmail(instructorSelected, "Assessment Form", sendmail.MailBody(finalLink)))
                {
                    //mail sending currently commented out

                    ViewBag.link = finalLink;
                    return View("MailResult");
                }
                else
                {
                    ViewBag.ErrorMsg = "Unable to send the link to the Instructor. Please check the network connections or else try sending the link personally. Here it the link below \n" +
                        "<h3>" + finalLink + "</h3>";
                    return View("Error");
                }
            }
        }
 public PartialViewResult EditCancel(int rowID)
 {
     using (var context = new AssessmentEntities())
     {
         var rubricRecord = context.spRUBRICSGETRECORD_RUBID(rowID).SingleOrDefault();
         spRUBRICGETSEARCHRESULTS_Result rubDetails = new spRUBRICGETSEARCHRESULTS_Result();
         rubDetails.RUBRIC_ROWID = rubricRecord.RUBRIC_ROWID;
         rubDetails.PERFORMANCE_INDICATOR = rubricRecord.PERFORMANCE_INDICATOR;
         rubDetails.TOPIC = rubricRecord.TOPIC;
         rubDetails.OUTCOMES = rubricRecord.OUTCOMES;
         rubDetails.POOR = rubricRecord.POOR;
         rubDetails.DEVELOPING = rubricRecord.DEVELOPING;
         rubDetails.DEVELOPED = rubricRecord.DEVELOPED;
         rubDetails.EXEMPLARY = rubricRecord.EXEMPLARY;
         rubDetails.EXPECTATION_LEVEL = rubricRecord.EXPECTATION_LEVEL;
         return PartialView("_RubricRows", rubDetails);
     }
 }
 public ActionResult Insert(USER_INFO userinfo)
 {
     using (var context = new AssessmentEntities())
     {
         try
         {
             var result = context.spInstructorAddNew(userinfo.INSTRUCTOR_NAME, userinfo.INSTRUCTOR_EMAILID);
             return RedirectToAction("AllInstructors");
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
             ViewBag.ErrorMsg = "Instructor Email ID already exist in the Database. Please use different one.";
             return View("Error");
         }
     }
 }
 public void DeleteRubricRecord(int rubID)
 {
     using (var context = new AssessmentEntities())
     {
         context.spRUBRIC_DELETE_RUBRICROW(rubID);
         context.SaveChanges();
     }
 }