Exemplo n.º 1
0
        public DTO.DistributorTransfer CreateDistributorTransfer(DataAccess.DistributorTransfer distributorTransfer, bool includeOnlyActive = true)
        {
            CheckHelper.ArgumentNotNull(distributorTransfer, "distributorTransfer");
            CheckHelper.ArgumentWithinCondition(!distributorTransfer.IsNew(), "!distributorTransfer.IsNew()");

            return
                (_dtoCache.Get(
                     distributorTransfer,
                     dt =>
            {
                var result =
                    new DTO.DistributorTransfer
                {
                    Id = dt.Id,
                    Amount = dt.Amount,
                    Date = dt.Date,
                    Active = dt.Active,
                    RublesPerDollar = dt.RublesPerDollar
                };

                CopyTrackableFields(result, dt);

                return result;
            }));
        }
        public void CreateDistributorTransfer(DTO.DistributorTransfer createdDistributorTransfer)
        {
            CheckHelper.ArgumentNotNull(createdDistributorTransfer, "createdDistributorTransfer");
            CheckHelper.ArgumentWithinCondition(createdDistributorTransfer.IsNew(), "Distributor Transfer is not new.");
            Container.Get <IValidateService>().CheckIsValid(createdDistributorTransfer);

            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");
            CheckHelper.WithinCondition(SecurityService.IsCurrentUserDistributor, "Only distributor can create distributor transfer.");

            var persistentService = Container.Get <IPersistentService>();

            var distributorTransfer =
                new DataAccess.DistributorTransfer
            {
                Date            = createdDistributorTransfer.Date,
                Amount          = createdDistributorTransfer.Amount,
                Active          = createdDistributorTransfer.Active,
                RublesPerDollar = createdDistributorTransfer.RublesPerDollar
            };

            distributorTransfer.UpdateTrackFields(Container);

            persistentService.Add(distributorTransfer);
            persistentService.SaveChanges();

            createdDistributorTransfer.Id         = distributorTransfer.Id;
            createdDistributorTransfer.CreateDate = distributorTransfer.CreateDate;
            createdDistributorTransfer.CreateUser = distributorTransfer.CreatedBy.GetFullName();
            createdDistributorTransfer.ChangeDate = distributorTransfer.ChangeDate;
            createdDistributorTransfer.ChangeUser = distributorTransfer.ChangedBy.GetFullName();
        }
Exemplo n.º 3
0
 public static void Reset()
 {
     _olesya_Transfer_1    = null;
     _olesya_Transfer_2    = null;
     _diana_Transfer_1     = null;
     _diana_Transfer_2     = null;
     _distributorTransfers = null;
 }