Ejemplo n.º 1
0
        public ActionResult UserRegistrationBlank(RegForm obj)
        {
            if (ModelState.IsValid)
            {

                UserProfile profile = new UserProfile();
                profile.LastName = obj.LastName;
                profile.FirstName = obj.FirstName;
                profile.ParentName = obj.ParentName;
                profile.DateOfBirth = obj.BirthDate;

                profile.DegreeID = obj.SelectedDegreeID;
                profile.LoginID = obj.LoginID;

                byte[] imgBuffer = null;
                if (obj.ImgFile != null)
                {
                    imgBuffer = new byte[obj.ImgFile.ContentLength];
                    using (Stream memStrm = obj.ImgFile.InputStream)
                    {
                        memStrm.Read(imgBuffer, 0, imgBuffer.Length);
                    }
                }

                profile.Photo = imgBuffer;

                if (_dbServices.saveModeltoDB(typeof(UserProfile), profile))

                    return RedirectToAction("UiResultUpdatable", "UiProfile", new { id = profile.UserProfileID });
                else
                    return RedirectToAction("Index", "Home");
            }

            return View(obj);
        }
        public ActionResult Create(UserProfile userprofile, HttpPostedFileBase ImgFile)
        {
            if (ModelState.IsValid)
            {
                byte[] imgBuffer = null;

                if (ImgFile != null)
                {
                    float imageWdth = float.Parse(Request["width"], CultureInfo.InvariantCulture);
                    float imageHeight = float.Parse(Request["height"], CultureInfo.InvariantCulture);
                    float imageX1 = float.Parse(Request["cor_x1"], CultureInfo.InvariantCulture);
                    float imageY1 = float.Parse(Request["cor_y1"], CultureInfo.InvariantCulture);
                    float imageX2 = float.Parse(Request["cor_x2"], CultureInfo.InvariantCulture);
                    float imageY2 = float.Parse(Request["cor_y2"], CultureInfo.InvariantCulture);
                    /*imgBuffer = new byte[ImgFile.ContentLength];*/
                    using (MemoryStream memStream = new MemoryStream())
                    {
                        using (Stream memStrm = ImgFile.InputStream)
                        {
                            Bitmap bmp = new Bitmap(memStrm);
                            Bitmap bmpCrop = bmp.Clone(new RectangleF(imageX1, imageY1, imageWdth, imageHeight),
                                                       bmp.PixelFormat);
                            bmpCrop.Save(memStream, ImageFormat.Jpeg);
                            /*memStrm.Read(imgBuffer, 0, imgBuffer.Length);*/
                        }
                        userprofile.Photo = memStream.GetBuffer();
                    }
                }

                userprofile.UserProfileID = Guid.NewGuid();
                db.UserProfile.AddObject(userprofile);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.LoginID = new SelectList(db.aspnet_Users, "UserId", "UserName", userprofile.LoginID);
            ViewBag.KeyID = new SelectList(db.KeyTable, "Id", "HostIdentity", userprofile.KeyID);
            ViewBag.DegreeID = new SelectList(db.MilitaryDegree, "DegreeID", "DegreeName", userprofile.DegreeID);
            ViewBag.Post_ID = new SelectList(db.Posts, "Post_ID", "PostName", userprofile.Post_ID);
            ViewBag.ObeysTo = new SelectList(db.UserProfile, "UserProfileID", "LastName", userprofile.ObeysTo);
            ViewBag.WorkArea_ID = new SelectList(db.WorkArea, "WorkArea_Id", "WA_Name", userprofile.WorkArea_ID);
            return View(userprofile);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UserProfile EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserProfile(UserProfile userProfile)
 {
     base.AddObject("UserProfile", userProfile);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a new UserProfile object.
 /// </summary>
 /// <param name="userProfileID">Initial value of the UserProfileID property.</param>
 public static UserProfile CreateUserProfile(global::System.Guid userProfileID)
 {
     UserProfile userProfile = new UserProfile();
     userProfile.UserProfileID = userProfileID;
     return userProfile;
 }