Ejemplo n.º 1
0
        public bool UpdateOne(SchoolUpdateModel model, int id)
        {
            try
            {
                var school = new School()
                {
                    Name = model.Name,
                    ID   = id
                };

                var result = Update(school, id);

                if (result != null)
                {
                    Log.Information("Updated school {0}", model.Name);

                    return(true);
                }

                return(false);
            }
            catch (System.Exception ex)
            {
                Log.Error(ex, "Exceptions occurred in school update");

                return(false);
            }
        }
        public IActionResult PutSchool([FromBody] SchoolUpdateModel school)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var result = unitOfWork.School.UpdateOne(school, school.ID);

                return(Ok(new { result }));
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Exceptions occurred in put school api");

                return(StatusCode(500, ex.Message));
            }
        }