Пример #1
0
        public ActionResult GetMovieData()
        {
            #region JQGrid Params
            string sortColumn = (Request.Params["sidx"]).ToString();
            string sortOrder = (Request.Params["sord"]).ToString();
            int pageIndex = Convert.ToInt32(Request.Params["page"]);    //Remember this is NOT 0 based
            int rowCount = Convert.ToInt32(Request.Params["rows"]);
            bool bSearch = Convert.ToBoolean(Request.Params["_search"]);
            #endregion
            PredictionRepository repository = new PredictionRepository();
            List<CMDetailPrediction> PredictionList;
            if (bSearch)
            {
                string FieldSearch = (Request.Params["searchField"]).ToString();
                string OperSearch = (Request.Params["searchOper"]).ToString();
                string sSearch = (Request.Params["searchString"]).ToString();
                PredictionList = repository.SearchPrediction(FieldSearch, OperSearch, sSearch).ToList();
            }
            else 
            {
                PredictionList = repository.ViewPrediction().ToList();
            }            

            
            int totalRecords = PredictionList.Count();
            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rowCount);

            var finalList = repository.Sort(PredictionList, sortColumn, sortOrder)
                                    .Skip((pageIndex - 1) * rowCount)
                                    .Take(rowCount);
            var jsonData = new 
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows = (
                    from m in finalList
                    select new
                    {
                        i = m.PredictionID,
                        cell = new string[] 
                        {
                            m.PredictionID.ToString(),       //[0] 
                            m.Topic,                         //[1] 
                            m.Description,                   //[2] 
                            m.CategoryName,                  //[3] 
                            m.UserName,                      //[4] 
                            m.Score.ToString(),              //[5] 
                            m.InsertDate.ToShortDateString(),//[6] 
                            m.HappenOnDate.ToString()        //[7]
                        }
                    }
                ).ToArray()
            };
            return Json(jsonData);
        }
Пример #2
0
        public void ShowPhoto(string username) 
        {
            MembershipUser user = Membership.GetUser(username);
            Guid guid = (Guid)user.ProviderUserKey;
            PredictionRepository repository = new PredictionRepository();
            PreMembership predictor = repository.GetMember(guid);

            if (predictor.Photo == null)
            {
                string physical = Server.MapPath("/Content/images/icon-amazing_03.png");
                predictor.Photo = System.IO.File.ReadAllBytes(physical);
            }

            Response.ContentType = "image/png";
            Response.OutputStream.Write(predictor.Photo.ToArray(), 0, predictor.Photo.Length); 
        }
Пример #3
0
 public MembershipCreateStatus CreateUser(string userName, string password, string email)
 {
     
     MembershipCreateStatus status;
     PredictionRepository repository = new PredictionRepository();
     var m = repository.Checkemail(email);
     if (m.Count() > 0)
     {
         return MembershipCreateStatus.DuplicateEmail;
     }
     else
     {
         _provider.CreateUser(userName, password, email, null, null, true, null, out status);
         return status;
     }
 }
Пример #4
0
 public ActionResult ChangeAccountInfo(string FirstName, string LastName, string Country)
 {
     MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name);
     Guid guid = (Guid)user.ProviderUserKey;
     PredictionRepository repository = new PredictionRepository();
     PreMembership predictor = repository.GetMember(guid);
     UpdateModel(predictor);
     repository.Save();
     return View("ChangeInfoSuccess");
 }
Пример #5
0
 public FileUploadJsonResult Upload(HttpPostedFileBase Photo)
 {
     MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name);
     Guid guid = (Guid)user.ProviderUserKey;
     PredictionRepository repository = new PredictionRepository();
     PreMembership predictor = repository.GetMember(guid);
     Photo = Request.Files["Photo"];
     MemoryStream ms = new MemoryStream();
     using (Image img = new Bitmap(Image.FromStream(Photo.InputStream), 200, 200))
     {
         img.Save(ms, ImageFormat.Png);
     }
     predictor.Photo = ms.ToArray();
     UpdateModel(predictor);
     repository.Save();
     System.Threading.Thread.Sleep(1000);
     // ++
     return new FileUploadJsonResult { Data = new { message = "success" } };
     
     // ++
 }
Пример #6
0
 public void changeAccount()
 {
     var firstname = Request.Form["FirstName"];
     var lastname = Request.Form["LastName"];
     var country = Request.Form["Country"];
     MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name);
     Guid guid = (Guid)user.ProviderUserKey;
     PredictionRepository repository = new PredictionRepository();
     PreMembership predictor = repository.GetMember(guid);
     if (predictor.FirstName == firstname && predictor.LastName == lastname && predictor.Country == country)
     {
         Response.Write("<div class='error'>You don't change any data.</div>");
     }
     else
     {
         UpdateModel(predictor);
         repository.Save();
         Response.Write("OK");
     }
 }