private long Save(UserProfile user, UserSelectedContext catalogInfo, string itemNumber, bool each, string catalogId) { RecentlyOrderedListHeader header = _headersRepo.GetRecentlyOrderedHeader(user.UserId, catalogInfo); RecentlyOrderedListDetail detail = new RecentlyOrderedListDetail { CatalogId = catalogId, ItemNumber = itemNumber, Each = each }; if (header == null) { // Create the header header = new RecentlyOrderedListHeader { Id = 0, BranchId = catalogInfo.BranchId, CustomerNumber = catalogInfo.CustomerId }; header.Id = _headersRepo.Save(header); } detail.HeaderId = header.Id; detail.CatalogId = catalogInfo.BranchId; _detailsRepo.Save(detail); return(header.Id); }
public void GoodDetail_ReturnsNullToDate() { // arrange RecentlyOrderedListDetail detail = MakeDetail(); // act ListItemModel results = detail.ToWebModel(); // assert results.ToDate .Should() .BeNull(); }
public void GoodDetail_ReturnsNullProprietaryCustomers() { // arrange RecentlyOrderedListDetail detail = MakeDetail(); // act ListItemModel results = detail.ToWebModel(); // assert results.ProprietaryCustomers .Should() .BeNull(); }
public void GoodDetail_ReturnsExpectedCustomInveotryItemId() { // arrange RecentlyOrderedListDetail detail = MakeDetail(); int expected = 0; // act ListItemModel results = detail.ToWebModel(); // assert results.CustomInventoryItemId .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedCreatedUtc() { // arrange RecentlyOrderedListDetail detail = MakeDetail(); DateTime expected = new DateTime(2017, 7, 20, 10, 44, 0, DateTimeKind.Utc); // act ListItemModel results = detail.ToWebModel(); // assert results.CreatedUtc .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedCatalogId() { // arrange RecentlyOrderedListDetail detail = MakeDetail(); string expected = "FUT"; // act ListItemModel results = detail.ToWebModel(); // assert results.CatalogId .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedActive() { // arrange RecentlyOrderedListDetail detail = MakeDetail(); bool expected = true; // act ListItemModel results = detail.ToWebModel(); // assert results.Active .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedItemNumber() { // arrange RecentlyOrderedListDetail detail = MakeDetail(); string expected = "123456"; // act ListItemModel results = detail.ToWebModel(); // assert results.ItemNumber .Should() .Be(expected); }
public void GoodDetail_ReturnsQuantityOfZero() { // arrange RecentlyOrderedListDetail detail = MakeDetail(); int expected = 0; // act ListItemModel results = detail.ToWebModel(); // assert results.Quantity .Should() .Be(expected); }
public void GoodDetail_ReturnsIsDeleteAsFalse() { // arrange RecentlyOrderedListDetail detail = MakeDetail(); bool expected = false; // act ListItemModel results = detail.ToWebModel(); // assert results.IsDelete .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedType() { // arrange RecentlyOrderedListDetail detail = MakeDetail(); ListType expected = ListType.RecentlyOrdered; // act ListItemModel results = detail.ToWebModel(); // assert results.Type .Should() .Be(expected); }
public void GoodDetail_ReturnsExpectedPosition() { // arrange RecentlyOrderedListDetail detail = MakeDetail(); int expected = 7; // act ListItemModel results = detail.ToWebModel(); // assert results.Position .Should() .Be(expected); }
public static ListItemModel ToWebModel(this RecentlyOrderedListDetail value) { return(new ListItemModel { ListItemId = value.Id, Type = ListType.RecentlyOrdered, ItemNumber = value.ItemNumber, ModifiedUtc = value.ModifiedUtc, CreatedUtc = value.CreatedUtc, Each = value.Each ?? false, CatalogId = value.CatalogId, Position = value.LineNumber, Active = true }); }
public void GoodModelWithoutHeaderId_ReturnsDefaultHeaderId() { // arrange int expected = 0; int headerId = 1; ListItemModel model = MakeModel(); // act RecentlyOrderedListDetail results = model.ToRecentlyOrderedDetailList(); // assert results.HeaderId .Should() .Be(expected); }
public void GoodModel_ReturnsExpectedLineNumber() { // arrange int expected = 23; int headerId = 1; ListItemModel model = MakeModel(); // act RecentlyOrderedListDetail results = model.ToRecentlyOrderedDetailList(); // assert results.LineNumber .Should() .Be(expected); }
public void GoodModel_ReturnsExpectedCatalogId() { // arrange string expected = "FUT"; int headerId = 1; ListItemModel model = MakeModel(); // act RecentlyOrderedListDetail results = model.ToRecentlyOrderedDetailList(); // assert results.CatalogId .Should() .Be(expected); }
public void GoodModel_ReturnsExpectedEach() { // arrange bool expected = true; int headerId = 1; ListItemModel model = MakeModel(); // act RecentlyOrderedListDetail results = model.ToRecentlyOrderedDetailList(); // assert results.Each .Should() .Be(expected); }
public long Save(RecentlyOrderedListDetail details) { DynamicParameters parms = new DynamicParameters(); parms.Add(PARMNAME_ID, details.Id); parms.Add(PARMNAME_HEADERID, details.HeaderId); parms.Add(PARMNAME_ITEMNUMBER, details.ItemNumber); parms.Add(PARMNAME_EACH, details.Each); parms.Add(PARMNAME_CATALOGID, details.CatalogId); parms.Add(PARMNAME_LINENUMBER, details.LineNumber); parms.Add(PARMNAME_RETURNVALUE, direction: ParameterDirection.Output, dbType: DbType.Int64); ExecuteSPCommand(SPNAME_SAVE, parms); return(parms.Get <long>(PARMNAME_RETURNVALUE)); }
public void NullEach_ReturnsNull() { // arrange var detail = new RecentlyOrderedListDetail() { CatalogId = "FRT", CreatedUtc = new DateTime(2017, 7, 5, 10, 49, 0, DateTimeKind.Utc), HeaderId = 1, ItemNumber = "567890", LineNumber = 5, ModifiedUtc = new DateTime(2017, 7, 5, 10, 50, 0, DateTimeKind.Utc) }; var repo = MakeRepo(); // act var detailId = repo.Save(detail); var results = repo.GetRecentlyOrderedDetails(detail.HeaderId); // assert results.First(x => x.Id.Equals(detailId)) .Each .Should() .BeNull(); }