public async Task <IActionResult> Create(QuantityTypeDto quantityTypeDto) { if (ModelState.IsValid) { await quantityTypeService.Create(quantityTypeDto); return(RedirectToAction("Index")); } return(View(quantityTypeDto)); }
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(); }
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(); } }