Пример #1
0
 public async Task CreateOrUpdateActivity(ActivityInputDto input)
 {
     if (input.Id != 0)
     {
         await UpdateActivity(input);
     }
     else
     {
         await CreateActivity(input);
     }
 }
Пример #2
0
        public async Task CreateActivity(ActivityInputDto input)
        {
            var act = input.MapTo <Activity>();
            var val = _activityRepository
                      .GetAll().Where(p => p.ActivityCode == input.ActivityCode || p.ActivityName == input.ActivityName).FirstOrDefault();

            if (val == null)
            {
                await _activityRepository.InsertAsync(act);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Activity Name '" + input.ActivityName + "' or Activity Code '" + input.ActivityCode + "'...");
            }
        }
Пример #3
0
        public async Task UpdateActivity(ActivityInputDto input)
        {
            var act = await _activityRepository.GetAsync(input.Id);

            ObjectMapper.Map(input, act);

            var val = _activityRepository
                      .GetAll().Where(p => (p.ActivityCode == input.ActivityCode || p.ActivityName == input.ActivityName) && p.Id != input.Id).FirstOrDefault();

            if (val == null)
            {
                await _activityRepository.UpdateAsync(act);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Activity Name '" + input.ActivityName + "' or Activity Code '" + input.ActivityCode + "'...");
            }
        }