Esempio n. 1
0
        public async Task <SavePersonResponse> SavePersonAsync(int id, Person person)
        {
            try
            {
                ValidateId(id);

                person.Id = id;
                if (person.GetType() == typeof(LeftPerson))
                {
                    await _personRepository.AddLeftPersonAsync(person as LeftPerson);
                }
                else
                {
                    await _personRepository.AddRightPersonAsync(person as RightPerson);
                }

                await _unitOfWork.CompleteAsync();

                return(new SavePersonResponse(person));
            }
            catch (Exception ex)
            {
                return(new SavePersonResponse($"An error occurred when saving the person: {ex.Message}"));
            }
        }