Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(EditUniversityViewModel viewModel, int id)
        {
            var model = await _service.EditAsync(new EditUniversityDTO { UniversityId = id, Name = viewModel.Name, Address = viewModel.Address });

            if (model == null)
            {
                return(new JsonResult(new ReturnMessage {
                    MessageContent = "Unexpected error when editing an university: University not found"
                })
                {
                    StatusCode = (int)HttpStatusCode.NotFound
                });
            }
            return(Ok(new UniversityViewModel {
                UniversityId = model.UniversityId, Address = model.Address, Name = model.Name
            }));
        }