Ejemplo n.º 1
0
        public async Task <Anag_Master> SaveAsync(AnagDTO dto = null, Anag_Master entity = null)
        {
            if (dto == null && entity == null)
            {
                throw new Exception($"{nameof(dto)} and {nameof(entity)} they were both null.");
            }
            if (dto != null && entity == null)
            {
                if (dto.Ang_ID > 0)
                {
                    entity = await FindByAsync(id : dto.Ang_ID);
                }
                entity ??= new Anag_Master();
                _mapper.Map(dto, entity);
            }

            if (dto?.Ang_ID <= 0 || entity.Ang_ID <= 0)
            {
                entity = await _repository.AddAsync(entity);
            }
            else
            {
                entity = await _repository.UpdateAsync(entity);
            }
            await _repository.UnitOfWork.SaveEntitiesAsync();

            return(entity);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int?angId)
        {
            var dto = new AnagDTO();

            if (angId.HasValue)
            {
            }

            return(View("Edit", dto));
        }