コード例 #1
0
        public async Task <IHttpActionResult> PuttSalt(int id, tSalt tSalt)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tSalt.Id)
            {
                return(BadRequest());
            }

            db.Entry(tSalt).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tSaltExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(tSalt));
        }
コード例 #2
0
        public async Task <IHttpActionResult> UpdateUser(int id, tUser tUser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tUser.ID)
            {
                return(BadRequest());
            }
            var user = await db.tUsers.FindAsync(id);

            user.PasswordHash = tUser.PasswordHash;

            if (user.PasswordHash != null)
            {
                PasswordStorage oPassUtil = new PasswordStorage();
                //oPassUtil.Hashstring = ;
                oPassUtil.CreateHash(user.PasswordHash);
                //oPassUtil.VerifyPassword
                user.PasswordHash = oPassUtil.Hashstring;

                tSalt salt = new tSalt {
                    Salt = oPassUtil.Saltstring
                };

                SaltsController sl = new SaltsController();
                user.tSalt = await sl.EditSalt(salt.Id, salt);

                if (user.tSalt != null)
                {
                    user.PHSaltID = tUser.tSalt.Id;
                }
            }
            db.Entry(user).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!tUserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            //return StatusCode(HttpStatusCode.NoContent);
            return(StatusCode(HttpStatusCode.OK));
        }
コード例 #3
0
        public IHttpActionResult PuttUsersAudit(int id, tUsersAudit tUsersAudit)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tUsersAudit.Id)
            {
                return(BadRequest());
            }

            db.Entry(tUsersAudit).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tUsersAuditExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #4
0
        public async Task <IHttpActionResult> PuttXrefUsersMaritalStatu(int id, tXrefUsersMaritalStatu tXrefUsersMaritalStatu)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tXrefUsersMaritalStatu.ID)
            {
                return(BadRequest());
            }

            db.Entry(tXrefUsersMaritalStatu).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tXrefUsersMaritalStatuExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #5
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "ID,FullName,Gender,PhoneNumber,Age,Adress,City,Country,Email,WebSite,Photo,AltTxt")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "Gender_Id,Gender1")] Gender gender)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gender).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gender));
 }
コード例 #8
0
        //This method to Update a user
        public void PUT(User user)
        {
            var User1 = db.Users.Find(user.Id);

            User1.Email          = user.Email;
            User1.FirstName      = user.FirstName;
            User1.LastName       = user.LastName;
            User1.PhoneNo        = user.PhoneNo;
            db.Entry(User).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
コード例 #9
0
 public ActionResult Edit(Blog blog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(blog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.userId = new SelectList(db.Users, "uId", "username", blog.userId);
     return(View(blog));
 }
コード例 #10
0
 public ActionResult Delete(UsersViewModel objuser)
 {
     using (var user = new UsersEntities())
     {
         var oneuser = user.People.Find(objuser.UserId);
         user.People.Attach(oneuser);
         user.Entry(oneuser).State = System.Data.EntityState.Deleted;
         user.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
コード例 #11
0
 public ActionResult Edit([Bind(Include = "Emp_Id,Full_Names,Gender_Id,Email")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Gender_Id = new SelectList(db.Genders, "Gender_Id", "Gender1", employee.Gender_Id);
     return(View(employee));
 }
コード例 #12
0
 public ActionResult Edit([Bind(Include = "Temp_Id,Emp_Id,Temperature1")] Temperature temperature)
 {
     if (ModelState.IsValid)
     {
         db.Entry(temperature).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Emp_Id = new SelectList(db.Employees, "Emp_Id", "Full_Names", temperature.Emp_Id);
     return(View(temperature));
 }