Esempio n. 1
0
        public async Task <Object> Putteacher(int id, teacher teacher)
        {
            if (!ModelState.IsValid)
            {
                return(Helper.JsonConverter.Error(410, "数据访问出错"));
            }

            if (id != teacher.t_id)
            {
                return(Helper.JsonConverter.Error(420, "用户已存在"));
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!teacherExists(id))
                {
                    return(Helper.JsonConverter.Error(420, "查无此人"));
                }
                else
                {
                    throw;
                }
            }

            return(Helper.JsonConverter.BuildResult("成功"));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> Putstudent_class(int id, student_class student_class)
        {
            if (!ModelState.IsValid)
            {
                return((IHttpActionResult)Helper.JsonConverter.Error(410, "数据访问出错"));
            }

            if (id != student_class.course_id)
            {
                return((IHttpActionResult)Helper.JsonConverter.Error(420, "查无此班级"));
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!student_classExists(id))
                {
                    return((IHttpActionResult)Helper.JsonConverter.Error(420, "查无此人"));
                }
                else
                {
                    throw;
                }
            }

            return((IHttpActionResult)Helper.JsonConverter.BuildResult("成功"));
        }
        public async Task <IHttpActionResult> Putdepartment(int id, department department)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != department.dep_id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }