示例#1
0
        public async Task <string> Put(int id, object user)
        {
            StudentRegisteration studentRegisteration = (StudentRegisteration)user;

            if (id != studentRegisteration.Id)
            {
                return("fail");
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Exists(id))
                {
                    return("fail");
                }
                else
                {
                    return("fail");
                }
            }

            return("success");
        }
示例#2
0
        public async Task <IActionResult> PostStudentRegisteration([FromBody] StudentRegisteration studentRegisteration)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _userBl("StudentRegisteration").Post(studentRegisteration);

            return(CreatedAtAction("GetStudentRegisteration", new { id = studentRegisteration.Id }, studentRegisteration));
        }
        public async Task <IActionResult> PostStudentRegisteration([FromBody] StudentRegisteration studentRegisteration)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.StudentRegisterations.Add(studentRegisteration);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetStudentRegisteration", new { id = studentRegisteration.Id }, studentRegisteration));
        }
示例#4
0
        public async Task <object> Get(int id)
        {
            var studentRegisteration = new StudentRegisteration();

            try
            {
                studentRegisteration = await _context.StudentRegisterations.FindAsync(id);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(studentRegisteration);
        }
示例#5
0
        public async Task <string> Post(object user)
        {
            StudentRegisteration studentRegisteration = (StudentRegisteration)user;

            try
            {
                _context.StudentRegisterations.Add(studentRegisteration);
                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                return("fail");
            }

            return("pass");
        }
        public async Task <IActionResult> PutStudentRegisteration([FromRoute] int id, [FromBody] StudentRegisteration studentRegisteration)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
示例#7
0
        public async Task <IActionResult> PutStudentRegisteration([FromRoute] int id, [FromBody] StudentRegisteration studentRegisteration)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            try
            {
                await _userBl("StudentRegisteration").Put(id, studentRegisteration);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentRegisterationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    return(NoContent());
                }
            }

            return(NoContent());
        }