public async Task <ActionResult <Platform> > PutPlatform(int id, PlatformInputDto input) { var platform = await _context.Platforms.FindAsync(id); platform.Name = input.Name; platform.ArabicName = input.ArabicName; platform.UpdatedUserId = input.UserId; platform.UpdatedDate = DateTime.Now; _context.Entry(platform).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlatformExists(id)) { return(NotFound()); } else { throw; } } return(platform); }
public async Task <ActionResult <Platform> > PostPlatform(PlatformInputDto input) { try { var platform = new Platform() { Name = input.Name, ArabicName = input.ArabicName, CreatedDate = DateTime.Now, CreatedUserId = input.UserId }; _context.Platforms.Add(platform); await _context.SaveChangesAsync(); return(platform); } catch (Exception ex) { return(null); } }