Beispiel #1
0
        public void VerifyAppointedBy(Guid wasAppointed, Guid appointer, ICloneableException <Exception> e)
        {
            var toRemove = Owners.FirstOrDefault(o => o.OwnerGuid.Equals(wasAppointed));

            if (toRemove == null)
            {
                toRemove = Managers.FirstOrDefault(m => m.OwnerGuid.Equals(wasAppointed));
            }
            if (toRemove == null)
            {
                StackTrace stackTrace = new StackTrace();
                var        msg        = $"User with Guid - {wasAppointed} is not an owner or manager of shop {Guid}" +
                                        $" cant complete {stackTrace.GetFrame(1).GetMethod().Name}";
                throw e.Clone(msg);
            }
            var byCreator = Creator.OwnerGuid.Equals(toRemove.AppointerGuid);
            var byOwner   = Owners.Any(o => o.OwnerGuid.Equals(toRemove.AppointerGuid));

            if (!(byCreator || byOwner))
            {
                StackTrace stackTrace = new StackTrace();
                var        msg        = $"User with Guid - {wasAppointed} was not appointed by {appointer}" +
                                        $" cant complete {stackTrace.GetFrame(1).GetMethod().Name}";
                throw e.Clone(msg);
            }
        }
Beispiel #2
0
 public void VerifyOwnerOrCreator(Guid ownerToRemoveGuid, ICloneableException <Exception> e)
 {
     if (!Owners.Any(owner => owner.OwnerGuid.Equals(ownerToRemoveGuid)) && !Creator.OwnerGuid.Equals(ownerToRemoveGuid))
     {
         StackTrace stackTrace = new StackTrace();
         var        msg        = $"User with Guid - {ownerToRemoveGuid} is not an owner" +
                                 $" cant complete {stackTrace.GetFrame(1).GetMethod().Name}";
         throw e.Clone(msg);
     }
 }
Beispiel #3
0
 public void VerifyOwnerOrManager(Guid newManagaerGuid, ICloneableException <Exception> e)
 {
     if (!IsOwnerOrManager(newManagaerGuid))
     {
         StackTrace stackTrace = new StackTrace();
         var        msg        = $"User with Guid - {newManagaerGuid} is not an owner or a creator or a manager" +
                                 $" cant complete {stackTrace.GetFrame(1).GetMethod().Name}";
         throw e.Clone(msg);
     }
 }
Beispiel #4
0
 public void VerifyNotCreator(Guid userGuid, ICloneableException <Exception> e)
 {
     if (!userGuid.Equals(Creator.OwnerGuid))
     {
         StackTrace stackTrace = new StackTrace();
         var        msg        = $"User with guid - {userGuid} Is a creator " +
                                 $" cant complete {stackTrace.GetFrame(1).GetMethod().Name}";
         throw e.Clone(msg);
     }
 }
Beispiel #5
0
 public void VerifyCreatorOrOwner(Guid userGuid, ICloneableException <Exception> e)
 {
     if (!IsCreatorOrOwner(userGuid))
     {
         StackTrace stackTrace = new StackTrace();
         var        msg        = $"User with guid - {userGuid} Is not a creator " +
                                 $"or an owner of the shop with guid - {ShopName}, cant complete {stackTrace.GetFrame(1).GetMethod().Name}";
         throw e.Clone(msg);
     }
 }
Beispiel #6
0
        public void VerifyShopProductExists(Guid shopProductGuid, ICloneableException <Exception> e)
        {
            var product = ShopProducts.FirstOrDefault(prod => prod.Guid.Equals(shopProductGuid));

            if (product == null)
            {
                StackTrace stackTrace = new StackTrace();
                var        msg        = string.Format(Resources.EntityNotFound, "product", shopProductGuid) +
                                        "In shop with Guid - {Guid}" + $" cant complete {stackTrace.GetFrame(1).GetMethod().Name}";
                throw e.Clone(msg);
            }
        }