Beispiel #1
0
        public async Task <RecordatoryTypeResponse> SaveAsync(RecordatoryType recordatoryType)
        {
            try
            {
                await _recordatoryTypeRepository.AddAsync(recordatoryType);

                await _unitOfWork.CompleteAsync();

                return(new RecordatoryTypeResponse(recordatoryType));
            }
            catch (Exception ex)
            {
                return(new RecordatoryTypeResponse($"An error ocurred while saving recordatory type: {ex.Message}"));
            }
        }
Beispiel #2
0
        public async Task <RecordatoryTypeResponse> UpdateAsync(int recordatoryTypeId, RecordatoryType recordatoryType)
        {
            var existingRecordatoryType = await _recordatoryTypeRepository.FindById(recordatoryTypeId);

            if (existingRecordatoryType == null)
            {
                return(new RecordatoryTypeResponse("Recordatory Type not found"));
            }
            existingRecordatoryType.Name = recordatoryType.Name;
            try
            {
                _recordatoryTypeRepository.Update(existingRecordatoryType);
                await _unitOfWork.CompleteAsync();

                return(new RecordatoryTypeResponse(existingRecordatoryType));
            }
            catch (Exception ex)
            {
                return(new RecordatoryTypeResponse($"An error ocurred while deleting recordatory type: {ex.Message}"));
            }
        }
Beispiel #3
0
 public void Remove(RecordatoryType recordatoryType)
 {
     _context.RecordatoryTypes.Remove(recordatoryType);
 }
Beispiel #4
0
 public void Update(RecordatoryType recordatoryType)
 {
     _context.RecordatoryTypes.Update(recordatoryType);
 }
Beispiel #5
0
 public async Task AddAsync(RecordatoryType recordatoryType)
 {
     await _context.RecordatoryTypes.AddAsync(recordatoryType);
 }