Beispiel #1
0
        public IActionResult Edit([FromBody] ManagerDto manager, int id)
        {
            var editedManager = new Manager
            {
                ManagerId = id,
                Name      = manager.Name,
                Title     = manager.Title
            };

            var editManager = new ManagerModifier(_repo).EditManager(editedManager);

            switch (editManager)
            {
            case StatusCodes.Success:
                return(StatusCode((int)HttpStatusCode.OK, $"{editedManager.Name} has been updated!"));

            case StatusCodes.NotFound:
                return(StatusCode((int)HttpStatusCode.NotFound, "Sorry, it does not look like that person exists."));

            case StatusCodes.Unsuccessful:
                return(StatusCode((int)HttpStatusCode.InternalServerError, "Sorry, something went wrong. Please try again later."));

            default:
                return(StatusCode((int)HttpStatusCode.InternalServerError, "Sorry, something went wrong. Please try again later."));
            }
        }
Beispiel #2
0
        public IActionResult Add([FromBody] ManagerDto manager)
        {
            var newManager = new Manager
            {
                Name  = manager.Name,
                Title = manager.Title
            };

            var addNewManager = _repo.AddNewManager(newManager);

            return(addNewManager
                ? StatusCode((int)HttpStatusCode.Created, $"{newManager.Name} has been added as a manager!")
                : StatusCode((int)HttpStatusCode.InternalServerError,
                             "Sorry, something went wrong. Please try again later."));
        }