public override async Task <BaseResponse> AddContactAsync(ContactData request, ServerCallContext context) { try { if (request is null) { await _peopleRepository.AddContactAsync(null); } Contact contact = new() { ContactType = (ContactType)System.Enum.Parse(typeof(ContactType), request.ContactType.ToString()), Name = request.Name, PersonId = request.PersonId, Value = request.Value }; int result = await _peopleRepository.AddContactAsync(contact); if (result == 0) { throw new Exception("Contact has not been saved"); } BaseResponse response = new() { Code = Code.Success, ErrorMessage = string.Empty, DataId = contact.Id }; LogData logData = new() { CallSide = nameof(PeopleService), CallerMethodName = nameof(AddContactAsync), CreatedOn = _dateTimeUtil.GetCurrentDateTime(), Request = request, Response = response }; _logger.AddLog(logData); return(response); } catch (NullReferenceException nrex) { LogData logData = new() { CallSide = nameof(PeopleService), CallerMethodName = nameof(AddContactAsync), CreatedOn = _dateTimeUtil.GetCurrentDateTime(), Request = request, Response = nrex }; _logger.AddErrorLog(logData); return(new BaseResponse { Code = Code.DataError, ErrorMessage = nrex.Message }); } catch (ArgumentException aex) { LogData logData = new() { CallSide = nameof(PeopleService), CallerMethodName = nameof(AddContactAsync), CreatedOn = _dateTimeUtil.GetCurrentDateTime(), Request = request, Response = aex }; _logger.AddErrorLog(logData); return(new BaseResponse { Code = Code.DataError, ErrorMessage = aex.Message }); } catch (DbUpdateException duex) { LogData logData = new() { CallSide = nameof(PeopleService), CallerMethodName = nameof(AddContactAsync), CreatedOn = _dateTimeUtil.GetCurrentDateTime(), Request = request, Response = duex }; _logger.AddErrorLog(logData); return(new BaseResponse { Code = Code.DbError, ErrorMessage = "An error occured while saving contact" }); } catch (Exception ex) { LogData logData = new() { CallSide = nameof(PeopleService), CallerMethodName = nameof(AddContactAsync), CreatedOn = _dateTimeUtil.GetCurrentDateTime(), Request = request, Response = ex }; _logger.AddErrorLog(logData); return(new BaseResponse { Code = Code.UnknownError, ErrorMessage = ex.Message }); } } public override async Task <BaseResponse> AddPhotoAsync(PhotoData request, ServerCallContext context)