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 static ListModel ToListModel(this RecentlyOrderedListHeader header, List <ListItemModel> items) { ListModel retVal = header.ToListModel(); retVal.Items = items.OrderBy(i => i.Position) .ToList(); return(retVal); }
public static ListModel ToListModel(this RecentlyOrderedListHeader header, List <RecentlyOrderedListDetail> items) { ListModel retVal = header.ToListModel(); retVal.Items = items.Select(i => i.ToWebModel()) .OrderBy(i => i.Position) .ToList(); return(retVal); }
public void DeleteAll(UserProfile user, UserSelectedContext catalogInfo) { RecentlyOrderedListHeader header = _headersRepo.GetRecentlyOrderedHeader(user.UserId, catalogInfo); if (header != null) { _detailsRepo.DeleteOldRecentlyOrdered(header.Id, 0); } }
public void GoodItem_ReturnsValue() { // arrange RecentlyOrderedListHeader test = MakeHeader(); Guid expected = Guid.Parse("12345678-1234-1234-1234-123456789012"); // act // assert test.UserId .Should() .Be(expected); }
public void GoodHeader_ItemsIsNotNull() { // arrange RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(); // assert results.Items .Should() .NotBeNull(); }
public void NewItem_UserIdHasDefaultValue() { // arrange RecentlyOrderedListHeader test = new RecentlyOrderedListHeader(); Guid expected = Guid.Parse("00000000-0000-0000-0000-000000000000"); // act // assert test.UserId .Should() .Be(expected); }
public void GoodHeader_ItemsIsNotNull() { // arrange List <ListItemModel> details = MakeListOfModels(); RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(details); // assert results.Items .Should() .NotBeNull(); }
public void GoodHeader_SharedWithIsNotNull() { // arrange RecentlyOrderedListHeader header = MakeHeader(); List <RecentlyOrderedListDetail> details = MakeListOfDetails(); // act ListModel results = header.ToListModel(details); // assert results.SharedWith .Should() .NotBeNull(); }
public long Save(RecentlyOrderedListHeader header) { DynamicParameters parms = new DynamicParameters(); parms.Add(PARMNAME_ID, header.Id); parms.Add(PARMNAME_USERID, header.UserId); parms.Add(PARMNAME_BRANCHID, header.BranchId); parms.Add(PARMNAME_CUSTOMERNUMBER, header.CustomerNumber); parms.Add(PARMNAME_RETURNVALUE, 0, dbType: DbType.Int64, direction: ParameterDirection.Output); ExecuteSPCommand(SPNAME_SAVE, parms); return(parms.Get <long>(PARMNAME_RETURNVALUE)); }
public void GoodHeader_ReturnsExpectedType() { // arrange ListType expected = ListType.RecentlyOrdered; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(); // assert results.Type .Should() .Be(expected); }
public void GoodHeader_ReturnsExpectedReadonly() { // arrange bool expected = true; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(); // assert results.ReadOnly .Should() .Be(expected); }
public void GoodHeader_ReturnsExpectedListId() { // arrange int expected = 15; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(); // assert results.ListId .Should() .Be(expected); }
public void GoodHeader_ReturnsExpectedName() { // arrange string expected = "Recently Ordered"; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(); // assert results.Name .Should() .Be(expected); }
public void GoodHeader_ReturnsExpectedIsWorksheet() { // arrange bool expected = false; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(); // assert results.IsWorksheet .Should() .Be(expected); }
public void GoodHeader_ReturnsExpectedHasContractItems() { // arrange bool expected = false; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(); // assert results.HasContractItems .Should() .Be(expected); }
public void GoodHeader_ReturnsExpectedCustomerNumber() { // arrange string expected = "123456"; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(); // assert results.CustomerNumber .Should() .Be(expected); }
public void GoodHeader_ItemsHasZeroCount() { // arrange int expected = 0; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(); // assert results.Items .Count .Should() .Be(expected); }
public void GoodHeader_ReturnsExpectedBranchId() { // arrange List <RecentlyOrderedListDetail> details = MakeListOfDetails(); string expected = "FUT"; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(details); // assert results.BranchId .Should() .Be(expected); }
public void GoodHeader_ReturnsExpectedIsSharing() { // arrange bool expected = false; RecentlyOrderedListHeader header = MakeHeader(); List <ListItemModel> details = MakeListOfModels(); // act ListModel results = header.ToListModel(details); // assert results.IsSharing .Should() .Be(expected); }
public void GoodHeader_ReturnsExpectedIsReminder() { // arrange List <RecentlyOrderedListDetail> details = MakeListOfDetails(); bool expected = false; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(details); // assert results.IsReminder .Should() .Be(expected); }
public void GoodHeader_ReturnsExpectedSharedWithCount() { // arrange int expected = 0; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(); // assert results.SharedWith .Count .Should() .Be(expected); }
public void GoodHeader_ReturnsExpectedName() { // arrange List <ListItemModel> details = MakeListOfModels(); string expected = "Recently Ordered"; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(details); // assert results.Name .Should() .Be(expected); }
public void GoodHeader_ItemsHasExpectedCount() { // arrange List <ListItemModel> details = MakeListOfModels(); int expected = 2; RecentlyOrderedListHeader header = MakeHeader(); // act ListModel results = header.ToListModel(details); // assert results.Items .Count .Should() .Be(expected); }
public ListModel ReadList(UserProfile user, UserSelectedContext catalogInfo, bool headerOnly) { RecentlyOrderedListHeader returnValue = _headersRepo.GetRecentlyOrderedHeader(user.UserId, catalogInfo); List <RecentlyOrderedListDetail> details = null; if (returnValue != null && headerOnly == false) { details = _detailsRepo.GetRecentlyOrderedDetails(returnValue.Id); } if (returnValue != null) { return(returnValue.ToListModel(details)); } return(null); }
public static ListModel ToListModel(this RecentlyOrderedListHeader header) { return(new ListModel { BranchId = header.BranchId, CustomerNumber = header.CustomerNumber, IsContractList = false, IsFavorite = false, IsWorksheet = false, IsReminder = false, IsMandatory = false, IsRecommended = false, IsCustomInventory = false, Type = ListType.RecentlyOrdered, ListId = header.Id, Name = LISTNAME_RECENTLY_ORDERED, ReadOnly = true }); }
public void GoodCustomer_ReturnsExpectedUserId() { // arrange Guid expected = new Guid(GOOD_USER_ID); UserSelectedContext fakeCustomer = new UserSelectedContext() { BranchId = "FDF", CustomerId = "123456" }; IRecentlyOrderedListHeadersRepository repo = MakeRepo(); // act RecentlyOrderedListHeader result = repo.GetRecentlyOrderedHeader(Guid.Parse(GOOD_USER_ID), fakeCustomer); // assert result.UserId .Should() .Be(expected); }