public async Task <RepositoryResultTypes> UpdateAsync(int id, UserInfo user)
        {
            if (id != user.Id)
            {
                return(RepositoryResultTypes.BadRequest);
            }

            _context.Entry(user).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserInfoExists(id))
                {
                    return(RepositoryResultTypes.NotFound);
                }
                else
                {
                    return(RepositoryResultTypes.Error);
                }
            }

            return(RepositoryResultTypes.NoContent);
        }
        public async Task <IActionResult> PutUserInfoItem(Guid id, UserInfoItem userInfoItem)
        {
            if (id != userInfoItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(userInfoItem).State = EntityState.Modified;

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

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "ID,UserName,UserPwd,Email,CreateDate,LastLoginDate")] UserInfoModel userInfoModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userInfoModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userInfoModel));
 }
Beispiel #4
0
 public ActionResult Edit([Bind(Include = "Id,Name,Phone,Email,Gender")] Info info)
 {
     if (ModelState.IsValid)
     {
         db.Entry(info).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(info));
 }
Beispiel #5
0
        public string ApproveUser(string userrole, int id, UserInfo objUserInfo)
        {
            userrole = userrole.ToLower();
            if (userrole == Constants.NORMALUSER)
            {
                return("Failed");
            }

            if (id != objUserInfo.UserId)
            {
                return("Failed");
            }

            _context.Entry(objUserInfo).State = EntityState.Modified;
            var saved = false;

            while (!saved)
            {
                try
                {
                    _context.SaveChanges();
                    saved = true;
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    foreach (var entry in ex.Entries)
                    {
                        if (entry.Entity is UserInfo)
                        {
                            var proposedValues = entry.CurrentValues;
                            var databaseValues = entry.GetDatabaseValues();

                            foreach (var property in proposedValues.Properties)
                            {
                                var proposedValue = proposedValues[property];
                                var databaseValue = databaseValues[property];
                            }
                            entry.OriginalValues.SetValues(databaseValues);
                        }
                    }
                }
            }
            return("Success");
        }