Esempio n. 1
0
        public ActionResult Institute()
        {
            InstituteDetailModel instituteDetailModel = new InstituteDetailModel();
            var model = instituteRepository.GetInstitute().FirstOrDefault();

            if (model != null)
            {
                instituteDetailModel.ID             = model.ID;
                instituteDetailModel.Name           = model.Name;
                instituteDetailModel.RegNo          = model.RegNo;
                instituteDetailModel.CertficateLink = model.CertficateLink;
            }
            return(View(instituteDetailModel));
        }
        // GET: Admin/Institute
        public ActionResult Index()
        {
            var model = instituteRepository.GetInstitute();

            return(View(model));
        }
Esempio n. 3
0
        public ActionResult Clicked(string username, string password)
        {
            Debug.WriteLine("One");


            //creating a user record

            /*
             * var u = new User()
             * {
             *  Name = "Yash",
             *  UserName = "******",
             *  Pass = "******",
             *  Designation = "HOD",
             *  Proposals = new List<Proposals>()
             *  {
             *      new Proposals()
             *      {
             *          Index = null,
             *          Title =  null,
             *          Institute= null,
             *          Dept= null,
             *          Course= null,
             *          Semester= null,
             *          Sub_type= null,
             *          Sub_code= null,
             *          Others_CC_text = null,
             *          Others_CC_file=null,
             *          Full_syll= null,
             *          Abstract= null,
             *          Objectives= null,
             *          Outcome= null,
             *          References= null,
             *          Incl_sem= null,
             *          Incl_sub_type= null,
             *          Others_CR_text=null,
             *          Others_CR_file=null,
             *          Present_split= null,
             *          Proposed_split= null,
             *          Present_nomenclature = null,
             *          New_nomenclature = null,
             *          With_effect_from=null,
             *          Modification_requested =null,
             *          Present_eligibility = null,
             *          Proposed_eligibility = null,
             *          Others_CS_text = null,
             *          Others_CS_file = null,
             *          Proposed_cname= null,
             *          Adm_capacity= null,
             *          Proposed_curriculum= null,
             *          Proposed_distribution = null
             *      }
             *  }
             * };
             */
            //Working COde for insertion
            //-----------
            //User a = _repositoryUser.InsertPost(u);
            //ViewBag.Result = a.ToJson().ToString();
            //-----------

            //working code
            //---------------------

            /*
             * string res = null;
             * List<User> a = _repositoryUser.SelectAll();
             * foreach( User s in a)
             * {
             *  if(res == null)
             *      res = s.ToJson().ToString();
             *  else
             *      res = res + s.ToJson().ToString();
             * }
             * ViewBag.Result = res;
             */
            //---------------------


            //Working Code for querying
            //-----------------

            /*
             * string res = null;
             * List<User> a = _repositoryUser.Filter("{UserName: '******', Pass:'******'}");
             * if (a == null)
             *  ViewBag.Result = "NotFound";
             * else
             * {
             *  foreach (User s in a)
             *  {
             *      if (res == null)
             *          res = s.ToJson().ToString();
             *      else
             *          res = res + s.ToJson().ToString();
             *  }
             *  if (res == null)
             *      ViewBag.Result = "NotFound";
             *  else
             *      ViewBag.Result = res;
             * }
             * ViewBag.Result = a.ToString();
             *
             * ViewBag.xyz = a.ToJson().ToString();
             */

            //-------------------
            string Entered_Uname = username;
            string Entered_Pass  = password;

            Debug.WriteLine("Two");
            if (Entered_Uname == null || Entered_Pass == null)
            {
                //return JavaScript(alert("please enter username and password"));
                Debug.WriteLine("Three");
                return(Content("<script language = 'javascript' type = 'text/javascript'>alert('please enter username and password'); window.location.href = 'login'</script>"));
            }
            Debug.WriteLine("Four");
            User curr_user = null;

            try
            {
                Debug.WriteLine("Five");
                List <User> Hits = _repositoryUser.Filter("{UserName: '******', Pass: '******'}");
                if (Hits == null)
                {
                    //ViewBag.Result = "Error!!";
                    Debug.WriteLine("Error");
                    return(Content("<script language = 'javascript' type = 'text/javascript'>alert('ERROR!!'); window.location.href = 'login'</script>"));
                }
                else
                {
                    foreach (User s in Hits)
                    {
                        if (s.ToJson().ToString() == null)
                        {
                            //ViewBag.Result = "Invalid Login";
                            Debug.WriteLine("Invalid");
                            return(Content("<script language = 'javascript' type = 'text/javascript'>alert('ERROR!!'); window.location.href = 'login'</script>"));
                        }
                        else
                        {
                            ViewBag.Result = "Welcome " + s.Name.ToString();
                            string UserName = s.UserName.ToString();
                            TempData["UserName"] = s.UserName;
                            Session["UserName"]  = s.UserName;
                            Session["Name"]      = s.Name;
                            //Session["Institute"] = s.Institute;
                            InstituteRepository i = new InstituteRepository();
                            Session["Institute"] = i.GetInstitute(s.Institute);
                            Session["Ins_id"]    = i.GetIns_Id(s.Institute);
                            return(RedirectToAction("Index", "Main"));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string error = e.ToString();
                return(Content("<script language = 'javascript' type = 'text/javascript'>alert('" + e + "'); window.location.href = 'login'</script>"));
            }

            /*
             * if (username.Equals("robby") && password.Equals("singh"))
             * {
             * // ViewBag.Result = "Right";
             *
             * }
             * else
             * {
             *  //ViewBag.Result = "Wrong";
             * }*/
            return(Content("<script language = 'javascript' type = 'text/javascript'>alert('Wrong Username/Password!!'); window.location.href = 'login'</script>"));
            //return View("login");
        }