public ListModel ReadList(UserProfile user, UserSelectedContext catalogInfo, bool headerOnly)
        {
            ListModel list = null;

            ReminderItemsListHeader header = _headersRepo.GetReminderItemsHeader(catalogInfo);

            if (header == null)
            {
                list = null;
            }
            else
            {
                if (headerOnly)
                {
                    list = header.ToListModel();
                }
                else
                {
                    List <ReminderItemsListDetail> items = _detailsRepo.GetRemindersDetails(header.Id);

                    list = header.ToListModel(items);
                }
            }
            return(list);
        }
Example #2
0
        public static ListModel ToListModel(this ReminderItemsListHeader header, List <ListItemModel> items)
        {
            ListModel retVal = header.ToListModel();

            retVal.Items = items.OrderBy(i => i.Position)
                           .ToList();
            return(retVal);
        }
Example #3
0
            public void GoodHeader_ItemsIsNotNull()
            {
                // arrange
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel();

                // assert
                results.Items
                .Should()
                .NotBeNull();
            }
        public long SaveReminderListHeader(ReminderItemsListHeader model)
        {
            DynamicParameters parms = new DynamicParameters();

            parms.Add(PARMNAME_BRANCH, model.BranchId);
            parms.Add(PARMNAME_CUSTNUM, model.CustomerNumber);
            parms.Add(PARMNAME_ID, model.Id);
            parms.Add(PARMNAME_RETVAL, 0, dbType: DbType.Int64, direction: ParameterDirection.Output);

            ExecuteSPCommand(SPNAME_SAVE, parms);

            return(parms.Get <long>(PARMNAME_RETVAL));
        }
Example #5
0
        public static ListModel ToListModel(this ReminderItemsListHeader header, List <ReminderItemsListDetail> items)
        {
            ListModel retVal = header.ToListModel();

            if (items != null)
            {
                retVal.Items = items.Select(i => i.ToWebModel())
                               .OrderBy(i => i.Position)
                               .ToList();
            }

            return(retVal);
        }
Example #6
0
            public void GoodHeader_ItemsIsNotNull()
            {
                // arrange
                List <ListItemModel>    details = MakeListOfModels();
                ReminderItemsListHeader header  = MakeHeader();

                // act
                ListModel results = header.ToListModel(details);

                // assert
                results.Items
                .Should()
                .NotBeNull();
            }
Example #7
0
            public void GoodHeader_ReturnsExpectedType()
            {
                // arrange
                ListType expected = ListType.Reminder;
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel();

                // assert
                results.Type
                .Should()
                .Be(expected);
            }
Example #8
0
            public void GoodHeader_ReturnsExpectedReadonly()
            {
                // arrange
                bool expected = false;
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel();

                // assert
                results.ReadOnly
                .Should()
                .Be(expected);
            }
Example #9
0
            public void GoodHeader_ReturnsExpectedName()
            {
                // arrange
                string expected = "Reminders";
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel();

                // assert
                results.Name
                .Should()
                .Be(expected);
            }
Example #10
0
            public void GoodHeader_ReturnsExpectedListId()
            {
                // arrange
                int expected = 15;
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel();

                // assert
                results.ListId
                .Should()
                .Be(expected);
            }
Example #11
0
            public void GoodHeader_ReturnsExpectedIsReminder()
            {
                // arrange
                bool expected = true;
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel();

                // assert
                results.IsReminder
                .Should()
                .Be(expected);
            }
Example #12
0
            public void GoodHeader_SharedWithIsNotNull()
            {
                // arrange
                ReminderItemsListHeader        header  = MakeHeader();
                List <ReminderItemsListDetail> details = MakeListOfDetails();

                // act
                ListModel results = header.ToListModel(details);

                // assert
                results.SharedWith
                .Should()
                .NotBeNull();
            }
Example #13
0
            public void GoodHeader_ReturnsExpectedCustomerNumber()
            {
                // arrange
                string expected = "123456";
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel();

                // assert
                results.CustomerNumber
                .Should()
                .Be(expected);
            }
Example #14
0
            public void GoodHeader_ReturnsExpectedSharedWithCount()
            {
                // arrange
                int expected = 0;
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel();

                // assert
                results.SharedWith
                .Count
                .Should()
                .Be(expected);
            }
Example #15
0
            public void GoodHeader_ReturnsExpectedIsSharing()
            {
                // arrange
                bool expected = false;
                ReminderItemsListHeader        header  = MakeHeader();
                List <ReminderItemsListDetail> details = MakeListOfDetails();

                // act
                ListModel results = header.ToListModel(details);

                // assert
                results.IsSharing
                .Should()
                .Be(expected);
            }
Example #16
0
            public void GoodHeader_ReturnsExpectedIsWorksheet()
            {
                // arrange
                List <ListItemModel> details = MakeListOfModels();
                bool expected = false;
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel(details);

                // assert
                results.IsWorksheet
                .Should()
                .Be(expected);
            }
Example #17
0
            public void GoodHeader_ItemsHasZeroCount()
            {
                // arrange
                int expected = 0;
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel();

                // assert
                results.Items
                .Count
                .Should()
                .Be(expected);
            }
Example #18
0
            public void GoodHeader_ReturnsExpectedBranchId()
            {
                // arrange
                List <ListItemModel> details = MakeListOfModels();
                string expected = "FUT";
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel(details);

                // assert
                results.BranchId
                .Should()
                .Be(expected);
            }
Example #19
0
            public void GoodHeader_ItemsHasExpectedCount()
            {
                // arrange
                List <ListItemModel> details = MakeListOfModels();
                int expected = 2;
                ReminderItemsListHeader header = MakeHeader();

                // act
                ListModel results = header.ToListModel(details);

                // assert
                results.Items
                .Count
                .Should()
                .Be(expected);
            }
Example #20
0
 public static ListModel ToListModel(this ReminderItemsListHeader header)
 {
     return(new ListModel()
     {
         BranchId = header.BranchId,
         CustomerNumber = header.CustomerNumber,
         IsContractList = false,
         IsFavorite = false,
         IsWorksheet = false,
         IsReminder = true,
         IsMandatory = false,
         IsRecommended = false,
         IsCustomInventory = false,
         Type = ListType.Reminder,
         ListId = header.Id,
         Name = LISTNAME_REMINDER,
         ReadOnly = false
     });
 }
        public ListModel SaveList(UserProfile user, UserSelectedContext catalogInfo, ListModel list)
        {
            ReminderItemsListHeader header = _headersRepo.GetReminderItemsHeader(catalogInfo);

            if (header == null)
            {
                if (list.Items.Count == 0)
                {
                    ReminderItemsListHeader model = new ReminderItemsListHeader()
                    {
                        BranchId       = catalogInfo.BranchId,
                        CustomerNumber = catalogInfo.CustomerId
                    };
                    _headersRepo.SaveReminderListHeader(model);
                }
                else
                {
                    foreach (var item in list.Items)
                    {
                        ReminderItemsListDetail detail = item.ToReminderItemsListDetail(0);
                        detail.Active = !item.IsDelete;
                        Save(catalogInfo, detail);
                    }
                }
            }
            else
            {
                foreach (var item in list.Items)
                {
                    ReminderItemsListDetail detail = item.ToReminderItemsListDetail(header.Id);
                    detail.Active = !item.IsDelete;
                    Save(catalogInfo, detail);
                }
            }

            return(GetListModel(user, catalogInfo, 0));
        }
        public void Save(UserSelectedContext catalogInfo, ReminderItemsListDetail model)
        {
            // try to find the parent header id if it is not in the model
            if (model.HeaderId == 0)
            {
                ReminderItemsListHeader header = _headersRepo.GetReminderItemsHeader(catalogInfo);

                if (header == null)
                {
                    // create the header
                    model.HeaderId = _headersRepo.SaveReminderListHeader(new ReminderItemsListHeader()
                    {
                        BranchId       = catalogInfo.BranchId,
                        CustomerNumber = catalogInfo.CustomerId
                    });
                }
                else
                {
                    model.HeaderId = header.Id;
                }
            }

            _detailsRepo.SaveReminderListDetail(model);
        }