Ejemplo n.º 1
0
 public async Task CreateOrUpdateFinished(FinishedInput input)
 {
     if (input.Id != 0)
     {
         await UpdateFinishedAsync(input);
     }
     else
     {
         await CreateFinishedAsync(input);
     }
 }
Ejemplo n.º 2
0
        public virtual async Task CreateFinishedAsync(FinishedInput input)
        {
            var Finish = input.MapTo <Finished>();
            var val    = _FinishedRepository.GetAll().Where(p => p.Code == input.Code || p.Name == input.Name).FirstOrDefault();

            if (val == null)
            {
                await _FinishedRepository.InsertAsync(Finish);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Name '" + input.Name + "' or Code '" + input.Code + "'...");
            }
        }
Ejemplo n.º 3
0
        public virtual async Task UpdateFinishedAsync(FinishedInput input)
        {
            var Finish = await _FinishedRepository.GetAsync(input.Id);

            ObjectMapper.Map(input, Finish);

            var val = _FinishedRepository.GetAll().Where(p => (p.Code == input.Code || p.Name == input.Name) && p.Id != input.Id).FirstOrDefault();

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