コード例 #1
0
ファイル: LeaseCrudVM.cs プロジェクト: peterson1/RentLog
 protected override void ClearDraftAfterSave()
 {
     DraftBirthDate = null;
     TenantTemplate = null;
     _pickedStall   = null;
     base.ClearDraftAfterSave();
 }
コード例 #2
0
        //internal static void RejectDuplicateName(this IStallsRepo repo, StallDTO newRecord)
        //{
        //    var matches = repo.GetAll().Where(_ => _.Name == newRecord.Name);

        //    if (matches.Any())
        //        throw DuplicateRecordsException.For(matches, nameof(newRecord.Name), newRecord.Name);
        //}


        internal static void DontDeleteIfOccupied(this IStallsRepo repo, StallDTO stall, IActiveLeasesRepo activeLses)
        {
            var lse = activeLses.GetAll().SingleOrDefault(_ => _.Stall.Id == stall.Id);

            if (lse != null)
            {
                throw Bad.Delete(stall, $"Occupied by {lse}");
            }
        }
コード例 #3
0
        public static bool TryPick(MarketStateDbBase marketStateDB, out StallDTO stall)
        {
            var win = CreateWindow();
            var vm  = new StallPickerVM(marketStateDB, win);
            var res = win.ShowDialog();

            stall = vm.PickedStall;
            return(res == true && stall != null);
        }
コード例 #4
0
        public override SectionDTO CastToRNT(dynamic byf)
        {
            var nme = As.Text(byf.label);

            return(new SectionDTO
            {
                Id = As.ID(byf.nid),
                Name = nme,
                IsActive = true,
                StallTemplate = StallDTO.Named(nme + " {0:000}"),
            });
        }
コード例 #5
0
 public LeaseColxnRow(SectionDTO sec, AmbulantColxnDTO dto)
 {
     Lease = new LeaseDTO
     {
         Tenant = TenantModel.Named(dto.ReceivedFrom),
         Stall  = StallDTO.Named($"{sec.Name} Section Ambulant")
     };
     AmbulantDTO = dto;
     DocumentRef = dto.PRNumber?.ToString();
     Ambulant    = dto.Amount;
     Remarks     = dto.Remarks;
 }
コード例 #6
0
        public override IDocumentDTO CastByfToDTO(object byfRecord)
        {
            var byf = Cast(byfRecord);
            var nme = byf.Label.Value.Trim();

            return(new SectionDTO
            {
                Id = (int)byf.Id.Value,
                Name = nme,
                StallTemplate = StallDTO.Named(nme + " {0:000}"),
                IsActive = byf.IsOperational
            });
        }
コード例 #7
0
        public void InsertRejectsduplicatestallname()
        {
            var moq   = new Mock <ISimpleRepo <StallDTO> >();
            var sut   = new StallsRepo1(moq.Object, null);
            var stall = StallDTO.Named("sample");

            moq.Setup(_ => _.GetAll())
            .Returns(new List <StallDTO> {
                stall
            });

            sut.Invoking(_ => _.Insert(stall))
            .Should().Throw <DuplicateRecordsException>();
        }
コード例 #8
0
        public LeaseDTO GetOccupant(StallDTO stall)
        {
            var matches = ActiveLeases.GetAll()
                          .Where(_ => _.Stall.Id == stall.Id);

            if (!matches.Any())
            {
                return(null);
            }
            if (matches.Count() > 1)
            {
                throw Bad.Data($"1 occupant for [{stall}] but found [{matches.Count()}]");
            }
            return(matches.Single());
        }
コード例 #9
0
        public void UpdateAcceptsnonnameedit()
        {
            var moq = new Mock <ISimpleRepo <StallDTO> >();
            var sut = new StallsRepo1(moq.Object, null);
            var rec = new StallDTO {
                Id = 1, Name = "Sample 1"
            };

            moq.Setup(_ => _.GetAll())
            .Returns(new List <StallDTO> {
                rec
            });

            rec.Name = rec.Name + " changed";
            sut.Update(rec);
        }
コード例 #10
0
ファイル: StallsJob.cs プロジェクト: peterson1/RentLog
        private static (RentParams Rent, RightsParams Rights) FindStallDefaults(StallDTO stall, ITenantDBsDir dir)
        {
            var mkt   = dir.MarketState;
            var match = FindLeaseIn(stall, mkt.ActiveLeases)
                        ?? FindLeaseIn(stall, mkt.InactiveLeases);

            if (match == null)
            {
                stall.Name += " *";//to prevent duplicates
                match       = new LeaseDTO
                {
                    Rent   = new RentParams(),
                    Rights = new RightsParams()
                };
            }
            return(match.Rent, match.Rights);
        }
コード例 #11
0
        public void CantDeleteifOccupied()
        {
            var moq   = new Mock <ISimpleRepo <StallDTO> >();
            var db    = new MockMarketState();
            var sut   = new StallsRepo1(moq.Object, db);
            var stall = StallDTO.Named("sample");

            db.MoqActiveLeases.Setup(_ => _.GetAll())
            .Returns(new List <LeaseDTO>
            {
                new LeaseDTO {
                    Stall = stall
                }
            });

            sut.Invoking(_ => _.Delete(stall)).Should()
            .Throw <InvalidDeletionException>();
        }
コード例 #12
0
        public void UpdateAcceptsUniquename()
        {
            var moq  = new Mock <ISimpleRepo <StallDTO> >();
            var sut  = new StallsRepo1(moq.Object, null);
            var rec1 = new StallDTO {
                Id = 1, Name = "Sample 1"
            };
            var rec2a = new StallDTO {
                Id = 2, Name = "Sample 2"
            };
            var rec2b = rec2a.ShallowClone <StallDTO>();

            moq.Setup(_ => _.GetAll())
            .Returns(new List <StallDTO> {
                rec1, rec2a
            });

            rec2b.Name = rec2a.Name + " changed";
            sut.Update(rec2b);
        }
コード例 #13
0
        public void Allowsduplicatenamediffsection()
        {
            var moq = new Mock <ISimpleRepo <StallDTO> >();
            var sut = new StallsRepo1(moq.Object, null);

            var rec1_1 = new StallDTO
            {
                Id      = 1,
                Name    = "Sample 1",
                Section = new SectionDTO {
                    Id = 1
                }
            };
            var rec1_2 = new StallDTO
            {
                Id      = 2,
                Name    = "Sample 2",
                Section = new SectionDTO {
                    Id = 1
                }
            };
            var rec2_1 = new StallDTO
            {
                Id      = 3,
                Name    = "Sample 1",
                Section = new SectionDTO {
                    Id = 2
                }
            };

            moq.Setup(_ => _.GetAll())
            .Returns(new List <StallDTO> {
                rec1_1, rec1_2, rec2_1
            });

            rec2_1.Remarks = "edit";

            sut.Update(rec2_1);
        }
コード例 #14
0
        public void UpdateRejectsduplicatestallname()
        {
            var moq  = new Mock <ISimpleRepo <StallDTO> >();
            var sut  = new StallsRepo1(moq.Object, null);
            var rec1 = new StallDTO {
                Id = 1, Name = "Sample 1"
            };
            var rec2 = new StallDTO {
                Id = 2, Name = "Sample 2"
            };
            var recX = rec2.ShallowClone <StallDTO>();

            moq.Setup(_ => _.GetAll())
            .Returns(new List <StallDTO> {
                rec1, rec2
            });

            recX.Name = rec1.Name;

            sut.Invoking(_ => _.Update(recX))
            .Should().Throw <DuplicateRecordsException>();
        }
コード例 #15
0
 public bool IsOccupied(StallDTO stall) => GetOccupant(stall) != null;
コード例 #16
0
ファイル: LeaseCrudVM.cs プロジェクト: peterson1/RentLog
 public void SetPickedStall(StallDTO stallDTO) => _pickedStall        = stallDTO;
コード例 #17
0
ファイル: StallsJob.cs プロジェクト: peterson1/RentLog
 private static LeaseDTO FindLeaseIn <T>(StallDTO stall, ISimpleRepo <T> repo)
     where T : LeaseDTO
 => repo.GetAll().FindLast(_ => _.Stall.Id == stall.Id);