Ejemplo n.º 1
0
        public async Task <IActionResult> Create(QuantityTypeDto quantityTypeDto)
        {
            if (ModelState.IsValid)
            {
                await quantityTypeService.Create(quantityTypeDto);

                return(RedirectToAction("Index"));
            }
            return(View(quantityTypeDto));
        }
Ejemplo n.º 2
0
        public async Task Create(QuantityTypeDto quantityTypeDto)
        {
            if (quantityTypeDto.IsActive == true)
            {
                SetAllNonActive();
            }
            var quantityType = new QuantityType()
            {
                Type        = quantityTypeDto.Type,
                Description = quantityTypeDto.Description,
                IsActive    = quantityTypeDto.IsActive,
            };

            await quantityTypeRepository.AddAsync(quantityType);

            await quantityTypeRepository.SaveChangesAsync();
        }
Ejemplo n.º 3
0
        public async Task Edit(QuantityTypeDto quantityTypeDto)
        {
            var quantityType = quantityTypeRepository.All().Where(e => e.Id == quantityTypeDto.Id).FirstOrDefault();

            if (quantityTypeDto.Id != 0 && quantityType != null)
            {
                if (quantityTypeDto.IsActive == true)
                {
                    SetAllNonActive();
                }

                quantityType.Type        = quantityTypeDto.Type;
                quantityType.Description = quantityTypeDto.Description;
                quantityType.IsActive    = quantityTypeDto.IsActive;

                quantityTypeRepository.Update(quantityType);
                await quantityTypeRepository.SaveChangesAsync();
            }
        }