public async Task <ActionResult <LicenceType> > PutLicenceType(int id, LicenceTypeInputDto input) { var licenceType = await _context.LicenceTypes.FindAsync(id); licenceType.Name = input.Name; licenceType.ArabicName = input.ArabicName; licenceType.UpdatedUserId = input.UserId; licenceType.UpdatedDate = DateTime.Now; _context.Entry(licenceType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LicenceTypeExists(id)) { return(NotFound()); } else { throw; } } return(licenceType); }
public async Task <ActionResult <LicenceType> > PostLicenceType(LicenceTypeInputDto input) { try { var licenceType = new LicenceType() { Name = input.Name, ArabicName = input.ArabicName, CreatedDate = DateTime.Now, CreatedUserId = input.UserId }; _context.LicenceTypes.Add(licenceType); await _context.SaveChangesAsync(); return(licenceType); } catch (Exception ex) { return(null); } }