Example #1
0
 protected override void ValidateBeforeDelete(LeaseDTO lse)
 {
     if (!_db.InactiveLeases.HasId(lse.Id))
     {
         throw Bad.Delete(lse, "Missing from Inactives");
     }
 }
Example #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}");
            }
        }