Esempio n. 1
0
 public IHttpActionResult EditUser(int id, DB.User user)
 {
     DB.User updtInfo = (from userdb in dc.User where userdb.id == id select userdb).FirstOrDefault();
     if (updtInfo != null)
     {
         updtInfo.full_name = user.full_name;
         updtInfo.email     = user.email;
         updtInfo.password  = user.password;
         dc.SubmitChanges();
     }
     else
     {
         return(NotFound());
     }
     return(Ok());
 }
Esempio n. 2
0
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="creationTime">Initial value of the CreationTime property.</param>
 /// <param name="companyId">Initial value of the CompanyId property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="roles">Initial value of the Roles property.</param>
 /// <param name="lastLogInTime">Initial value of the LastLogInTime property.</param>
 /// <param name="isActive">Initial value of the IsActive property.</param>
 /// <param name="languageId">Initial value of the LanguageId property.</param>
 /// <param name="isForManagment">Initial value of the IsForManagment property.</param>
 public static User CreateUser(global::System.Int32 id, global::System.DateTime creationTime, global::System.Int32 companyId, global::System.String email, global::System.String firstName, global::System.String lastName, global::System.Int32 roles, global::System.DateTime lastLogInTime, global::System.Boolean isActive, global::System.Int32 languageId, global::System.Boolean isForManagment)
 {
     User user = new User();
     user.Id = id;
     user.CreationTime = creationTime;
     user.CompanyId = companyId;
     user.Email = email;
     user.FirstName = firstName;
     user.LastName = lastName;
     user.Roles = roles;
     user.LastLogInTime = lastLogInTime;
     user.IsActive = isActive;
     user.LanguageId = languageId;
     user.IsForManagment = isForManagment;
     return user;
 }
Esempio n. 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }
Esempio n. 4
0
 public IHttpActionResult AddUser(DB.User user)
 {
     dc.User.InsertOnSubmit(user);
     dc.SubmitChanges();
     return(Ok());
 }
        public /*JsonResult*/ ActionResult SaveUsers(User u)
        {
            string password  = Request["password1"];
            string password2 = Request["cn_password"];

            if (password != password2)
            {
                return(Content("<script>alert('Password mismatch!!!');var data = new{success = false};document.location='login'</script>"));
            }

            var uniqueName = "";

            if (Request.Files["Image"] != null)
            {
                var file = Request.Files["Image"];
                if (file.FileName != "")
                {
                    var ext = System.IO.Path.GetExtension(file.FileName);

                    //Generate a unique name using Guid
                    uniqueName = Guid.NewGuid().ToString() + ext;

                    //Get physical path of our folder where we want to save images
                    // var rootPath = Server.MapPath("~/UploadedFiles");
                    var rootPath = "C:/Users/Tayyibah/Documents/GitHub/E-Shopper/EAD_Project/UploadedFiles";

                    var fileSavePath = System.IO.Path.Combine(rootPath, uniqueName);

                    // Save the uploaded file to "UploadedFiles" folder
                    file.SaveAs(fileSavePath);

                    u.PictureName = uniqueName;
                }
            }
            using (var context = new Shopping_DBEntities4())
            {
                var student = new DB.User
                {
                    Name        = u.Name,
                    Login       = u.Name,
                    Password    = password,
                    isAdmin     = false,
                    isActive    = true,
                    PictureName = u.PictureName,
                    Designation = u.Designation,
                    Email       = u.Email
                };
                context.Users.Add(student);
                context.SaveChanges();
                var data = new
                {
                    success = true,
                    //ProductID = pid,
                    //PictureName = u.PictureName
                };
                if (student != null)
                {
                    // return Json(data, JsonRequestBehavior.AllowGet); return Json(data, JsonRequestBehavior.AllowGet);
                    return(Content("<script>alert('thanks for registering!!!'); var data = new{success = true}; document.location='NormalUser'</script>"));
                }
                // return View();
                else
                {
                    return(Content("<script>alert('registering unsuccessful!!!'); var data = new{success = false}; document.location='NormalUser'</script>"));
                }
            }
            //   return Content("<script>alert('registering unsuccessful!!!'); var data = new{success = false}; document.location='NormalUser'</script>");
        }