示例#1
0
        public bool UpdateStaffMemberName(UpdateStaffMemberName sm, int staffId)
        {
            if (!_repository.StaffMemberExists(staffId))
            {
                return(false);
            }

            var staffToUpdate      = _repository.GetStaffMember(staffId);
            var updatedStaffMember = Mapper.Map(sm, staffToUpdate);

            UtilityMethods.VerifyDatabaseSaveSuccess(_repository);

            return(true);
        }
示例#2
0
        public IActionResult UpdateStaffMemberName(int staffId,
                                                   [FromBody] UpdateStaffMemberName sm)
        {
            try
            {
                bool updateSucceded = _staffCore.UpdateStaffMemberName(sm, staffId);

                if (!updateSucceded)
                {
                    return(StatusCode(500, errorMsg));
                }
                return(NoContent());
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"An error occured while trying to perform a name change on the Staff Member with the id: {staffId}");
                ModelState.AddModelError("Update Name Failed: ", e.Message);
                return(StatusCode(500, ModelState));
            }
        }