示例#1
0
        public ActionResult SaveProfile(UserViewModel model, HttpPostedFileBase file)
        {
            if (String.IsNullOrEmpty(model.UserFullName) || String.IsNullOrEmpty(model.Password) || string.IsNullOrEmpty(model.Email))
            {
                ViewBag.SuccessMsg = "Please, fill all required fileds";
                return(View("Index"));
            }
            UserViewModel user = (UserViewModel)Session[SessionEnum.User_Info.ToString()]; // User session.

            if (file != null)
            {
                if (file != null && file.ContentLength > 0)
                {
                    SaveImageOnserver.SaveImg(file, "~/Images/Profile/", 200, 200, Convert.ToInt32(user.UserID));
                }
            }

            // update DB.

            UserService   service   = new UserService();
            UserViewModel Usermodel = new UserViewModel()
            {
                UserID       = user.UserID,
                UserFullName = model.UserFullName,
                Password     = EncryptDecryptString.Encrypt(model.Password, "Taj$$Key"),
                Address      = model.Address,
                Phone        = user.Phone,
                Username     = user.Username,
                Country      = user.Country,
                Email        = model.Email,
                Mobile       = user.Mobile,
                Nationality  = user.Nationality
            };

            if (file != null)
            {
                Usermodel.Image = Path.GetExtension(file.FileName);
            }
            else
            {
                Usermodel.Image = user.Image;
            }

            int ResultDB = service.Update(Usermodel);

            // Update user sesstion.
            Session[SessionEnum.User_Info.ToString()] = Usermodel;

            ViewBag.SuccessMsg = "Your data saved successfully";
            return(View("Index"));
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            if (context.Request.Files.Count > 0)
            {
                // save img with Row Id
                string        Id         = context.Request["Id"];
                string[]      ArrIds     = Id.Split('_');
                List <string> finalCount = new List <string>();
                for (int i = 0; i < ArrIds.Length; i++)
                {
                    if (!String.IsNullOrEmpty((ArrIds[i])))
                    {
                        finalCount.Add(ArrIds[i]);
                    }
                }

                //--------------------------------------------------------------------------------------------------------------
                HttpFileCollection files = context.Request.Files;
                for (int i = 0; i < files.Count; i++)
                {
                    //System.Threading.Thread.Sleep(1000);
                    HttpPostedFile file = files[i];

                    //------------------------------------- when we upload with original zise ---------------------------------
                    //string filename = context.Server.MapPath("~/Uploads/" + System.IO.Path.GetFileName(file.FileName));
                    //file.SaveAs(filename);
                    //----------------------------------------------------------------------------------------------------------

                    //---------------- save withe edit on with and height-------------------------------------------------------

                    SaveImageOnserver.SaveImg(file, "../Images/Property/", 380, 370, int.Parse(finalCount[i]));

                    //ImageInfo info = new ImageInfo() { ImgExt = System.IO.Path.GetExtension(file.FileName) };

                    //JavaScriptSerializer js = new JavaScriptSerializer();
                    //context.Response.Write(js.Serialize(info));
                }
            }
        }