public override SeatInformation GetSeatInformation(int seatNumber) { SeatCategory category = new SeatCategory(); SeatSection section = new SeatSection(); if (seatNumber % 3 == 1) { section = SeatSection.LeftSide; category = SeatCategory.Singular; } else { section = SeatSection.RightSide; if (seatNumber % 3 == 2) { category = SeatCategory.Corridor; } else if (seatNumber % 3 == 0) { category = SeatCategory.Window; } } SeatInformation seatInformation = new SeatInformation(seatNumber, section, category); return(seatInformation); }
public async Task <bool> DeleteAsync(SeatCategory item) { if (item == null || item.SeatCategoryId <= 0) { throw new ArgumentException(nameof(item)); } return(await dbContext.SeatCategoryDao.DeleteAsync(item.SeatCategoryId)); }
public async Task <bool> UpdateAsync(SeatCategory data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } return(await dbContext.SeatCategoryDao.UpdateAsync(data)); }
public async Task InsertAsyncTest() { var seatcategory = new SeatCategory { CategoryName = "Test Category", Price = 10.0f }; var status = await seatCategoryLogic.InsertAsync(seatcategory); Assert.True(status); }
public async Task <bool> UpdateAsync(SeatCategory item) { return(await adoTemplate.ExecuteAsync(@"UPDATE SeatCategory SET CategoryName = @CName , Price = @Price WHERE SeatCategoryId = @SCId", new QueryParameter("@CName", item.CategoryName), new QueryParameter("@Price", item.Price), new QueryParameter("@SCId", item.SeatCategoryId)) == 1); }
public async Task DeleteAsyncTest() { var seatcategory = new SeatCategory { SeatCategoryId = 1 }; var status = await seatCategoryLogic.DeleteAsync(seatcategory); Assert.True(status); }
public async Task UpdateAsyncTest() { var seatcategory = new SeatCategory { SeatCategoryId = 3, Price = 10.0f, CategoryName = "Updated" }; var status = await seatCategoryLogic.UpdateAsync(seatcategory); Assert.True(status); }
public override SeatInformation GetSeatInformation(int seatNumber) { SeatSection section = (seatNumber % 2 == 0) ? SeatSection.RightSide : SeatSection.LeftSide; SeatCategory category = SeatCategory.Window; SeatInformation inf = new SeatInformation(seatNumber, section, category); return(inf); }
public async Task TestInsertAsync() { var category = new SeatCategory { CategoryName = "Test Category", Price = 5.0 }; Assert.True(await adoDatabaseContext.SeatCategoryDao.InsertAsync(category)); Assert.NotZero(category.SeatCategoryId); }
public override SeatInformation GetSeatInformation(int seatNumber) { SeatSection section = (seatNumber % 3 == 1) ? SeatSection.LeftSide : SeatSection.RightSide; SeatCategory category = (seatNumber % 3 == 1) ? SeatCategory.Singular : (seatNumber % 3 == 2) ? SeatCategory.Corridor : SeatCategory.Window; SeatInformation inf = new SeatInformation(seatNumber, section, category); return(inf); }
public async Task <bool> InsertAsync(SeatCategory sc) { var seatCategoryId = await adoTemplate.ExecuteScalarAsync(@"INSERT INTO SeatCategory(CategoryName, Price) output inserted.SeatCategoryId VALUES(@CName, @Price)", new QueryParameter("@CName", sc.CategoryName), new QueryParameter("@Price", sc.Price)); if (seatCategoryId != default) { sc.SeatCategoryId = seatCategoryId; return(await Task.FromResult(true)); } return(await Task.FromResult(false)); }
public async Task <ActionResult> Update([FromBody] SeatCategory data) { if (await seatCategoryLogic.FindByIdAsync(data.SeatCategoryId) == null) { return(NotFound()); } if (await seatCategoryLogic.UpdateAsync(data)) { return(NoContent()); } return(BadRequest("Error processing request!")); }
public async Task <bool> InsertAsync(SeatCategory sc) { if (sc == null) { throw new ArgumentNullException(nameof(sc)); } if (sc.SeatCategoryId <= 0) { mockedSeatCategories.Add(sc); return(await Task.FromResult(true)); } return(await Task.FromResult(false)); }
public async Task <ActionResult> Insert([FromBody] SeatCategory data) { try { if (await seatCategoryLogic.InsertAsync(data)) { return(CreatedAtAction(nameof(Get), new { id = data.SeatCategoryId }, data)); } return(BadRequest("Error Processing Request!")); } catch (ArgumentException) { return(Conflict(data)); } }
public async Task TestUpdateAsync() { var testCategory = new SeatCategory { SeatCategoryId = 5, CategoryName = "Updated Test Entry", Price = 2.0 }; var successful = await adoDatabaseContext.SeatCategoryDao.UpdateAsync(testCategory); Assert.True(successful); var category = await adoDatabaseContext.SeatCategoryDao.FindByIdAsync(5); Assert.AreEqual(testCategory.CategoryName, category.CategoryName); Assert.AreEqual(testCategory.Price, category.Price); }
public override SeatInformation GetSeatInformation(int seatNumber) { SeatSection section = new SeatSection(); SeatCategory category = new SeatCategory(); if (seatNumber % 2 == 1) { section = SeatSection.LeftSide; } else { section = SeatSection.RightSide; } category = SeatCategory.Singular; SeatInformation seatInf = new SeatInformation(seatNumber, section, category); return(seatInf); }
public override SeatInformation GetSeatInformation(int seatNumber) { SeatCategory sCategory = new SeatCategory(); SeatSection sSection = new SeatSection(); if (seatNumber % 2 == 1) { sCategory = SeatCategory.Singular; sSection = SeatSection.LeftSide; } else { sCategory = SeatCategory.Singular; sSection = SeatSection.LeftSide; } SeatInformation seatInformation = new SeatInformation(seatNumber, sSection, sCategory); return(seatInformation); }
public async Task <bool> UpdateAsync(SeatCategory item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (item.SeatCategoryId != 0) { var seatCategories = (from x in mockedSeatCategories where x.SeatCategoryId == item.SeatCategoryId select x).FirstOrDefault(); seatCategories.CategoryName = item.CategoryName; seatCategories.Price = item.Price; return(await Task.FromResult(true)); } return(await Task.FromResult(false)); }
public SeatInformation(int number, SeatSection section, SeatCategory category) { Number = number; Section = section; Category = category; }
public SeatInformation(int Number, SeatSection Section, SeatCategory Category) { this.Number = Number; this.Section = Section; this.Category = Category; }
public Seat(SeatCategory category, string number) { Category = category; Number = number; AssociatedNumber = category == SeatCategory.Couples ? number + "A" : null; }