Ejemplo n.º 1
0
        public IHttpActionResult Put(string id, AccountStudent accountStudent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != accountStudent.stu_userName)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public IHttpActionResult Get(string id)
        {
            IHttpActionResult ret = null;
            AccountStudent    stu = new AccountStudent();

            stu = db.AccountStudents.SingleOrDefault(s => s.stu_userName.Equals(id));
            if (stu == null)
            {
                ret = NotFound();
            }
            else
            {
                ret = Ok(stu);
            }
            return(ret);
        }