Ejemplo n.º 1
0
 /// <summary>
 /// Return the customer with the given CustomerId, or null if not found
 /// </summary>
 public Customer GetById(CustomerId id)
 {
     var db = new DbContext();
     
     // Note that this code does not trap exceptions coming from the database. What would it do with them?
     // Compare with the F# version, where errors are returned along with the Customer
     return db.Customers().Where(c => c.Id == id.Id).Select(FromDbCustomer).FirstOrDefault();
 }
Ejemplo n.º 2
0
        public CustomerNameChanged(CustomerId customer, Name originalName, Name currentName)
        {
            customer.VerifyArgumentNotDefaultValue("Customer is required");
            originalName.VerifyArgumentNotDefaultValue("Original name is required");
            currentName.VerifyArgumentNotDefaultValue("Current name is required");

            this.Customer = customer;
            this.OriginalName = originalName;
            this.CurrentName = currentName;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a new customer from the parameters. If not valid, return null
        /// </summary>
        public static Customer Create(CustomerId id, PersonalName name, EmailAddress email)
        {
            if (id == null) { return null; }
            if (name == null) { return null; }
            if (email == null) { return null; }

            // Compare this with the F# version, where the domain object
            // doesn't need to check for nulls

            return new Customer { Id = id, Name = name, EmailAddress = email };
        }
Ejemplo n.º 4
0
        public async Task <ViewDTO> GetForCustomerAsync(CustomerId customerId)
        {
            var sqlParams = new
            {
                CustomerId = customerId.RawValue
            };
            string sql = @";
                SELECT Id, 
                       CustomerId,
                       AccessKey,
                       Content
                FROM dbo.Views V
                WHERE V.CustomerId = @CustomerId;
            ";

            return(await GetSingleOrDefaultAsync(sql, sqlParams));
        }
Ejemplo n.º 5
0
        public override int GetHashCode()
        {
            int hashCode = 1218412534;

            hashCode = hashCode * -1521134295 + Id.GetHashCode();
            hashCode = hashCode * -1521134295 + CustomerId.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <Customer> .Default.GetHashCode(Customer);

            hashCode = hashCode * -1521134295 + EqualityComparer <List <OrderItem> > .Default.GetHashCode(OrderItems);

            hashCode = hashCode * -1521134295 + TotalPrice.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(OrderTime);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(OrderState);

            return(hashCode);
        }
Ejemplo n.º 6
0
        public override bool Equals(object obj)
        {
            var other = obj as CustomerNameChanged;

            if (other == null)
            {
                return(false);
            }
            bool result = EventIdentifier.Equals(other.EventIdentifier) &&
                          EventSourceId.Equals(other.EventSourceId) &&
                          EventSequence.Equals(other.EventSequence) &&
                          EventTimeStamp.Equals(other.EventTimeStamp) &&
                          CustomerId.Equals(other.CustomerId) &&
                          NewName.Equals(other.NewName);

            return(result);
        }
Ejemplo n.º 7
0
        public SessionIdentity(
            UserId user,
            SecurityId customer,
            string userName,
            string cookieString,
            IEnumerable <string> permissions,
            string token)
        {
            User           = user;
            Security       = customer;
            UserName       = userName;
            SessionDisplay = String.Format("{0} ({1})", UserName, customer.Id);

            CookieString = cookieString;
            Customer     = new CustomerId(customer.Id);
            Permissions  = new HashSet <string>(permissions);
            Token        = token;
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (CustomerId.Length != 0)
            {
                hash ^= CustomerId.GetHashCode();
            }
            if (operation_ != null)
            {
                hash ^= Operation.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
 public static BankAccount From(
     BankAccountId bankAccountId,
     BankAccountNumber bankAccountNumber,
     Money balance,
     BankAccountStateId bankAccountStateId,
     DateTime createdAt,
     DateTime updatedAt,
     CustomerId customerId)
 {
     return(new BankAccount(
                bankAccountId,
                bankAccountNumber,
                balance,
                bankAccountStateId,
                createdAt,
                updatedAt,
                customerId));
 }
Ejemplo n.º 10
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (BillingAddress != null ? BillingAddress.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CardBrand != null ? CardBrand.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CardExpMonth.GetHashCode();
         hashCode = (hashCode * 397) ^ CardExpYear.GetHashCode();
         hashCode = (hashCode * 397) ^ (CardLast4 != null ? CardLast4.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CustomerId.GetHashCode();
         hashCode = (hashCode * 397) ^ HasCardErrorInDunning.GetHashCode();
         hashCode = (hashCode * 397) ^ (PaymentType != null ? PaymentType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ProcessorName != null ? ProcessorName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (StatusReason != null ? StatusReason.GetHashCode() : 0);
         return(hashCode);
     }
 }
        public void ItShouldReturnsCustomerWhenFindByIdisExecuted()
        {
            //Arrange
            var fakeLoggingService = new FakeLoggingService();
            var customerRepository = new CustomerRepository(fakeLoggingService);

            CustomerId   customerId   = new CustomerId(1234);
            CustomerName customerName = new CustomerName("customer");
            Customer     customer     = Customer.Create(customerId, customerName);

            //Act
            var actual = customerRepository.FindById(customerId);

            //Assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(customer.Id(), actual.Id());
            Assert.AreEqual(customer.Name(), actual.Name());
        }
Ejemplo n.º 12
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CustomerId.Length != 0)
            {
                hash ^= CustomerId.GetHashCode();
            }
            if (DisplayName.Length != 0)
            {
                hash ^= DisplayName.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 13
0
        public void ItShouldReturnTrueIfUseCaseExecutedIsValid()
        {
            var mockRepository = new Mock <CustomerRepository>();
            var mockConverter  = new Mock <CustomerConverter>();

            var createCustomerUseCase = new CreateCustomerUseCase(mockRepository.Object, mockConverter.Object);

            CustomerId   id       = new CustomerId("1111");
            CustomerName name     = new CustomerName("customer");
            Customer     customer = Customer.SignUp(id, name);

            CreateCustomerRequest request = new CreateCustomerRequest(id.Id(), name.Name());

            var actual = createCustomerUseCase.Execute(request);

            Assert.AreEqual("1111", actual.Id);
            Assert.AreEqual("customer", actual.Name);
        }
Ejemplo n.º 14
0
        public void Cancel(TenantId tenantId, BookingId bookingId, CustomerId customerId, string reason)
        {
            using (var uow = _unitOfWorkFactory.CreateSession())
            {
                // Get booking, open for tender and commit
                var booking = uow.GetRepository <IBookingWriteRepository>().Get(bookingId);

                // Sanity check: Owner of booking must match specified customer
                if (booking.CustomerId != customerId)
                {
                    throw new ArgumentException(
                              "Booking is owned by different customer.",
                              nameof(customerId));
                }

                booking.Cancel(reason);
                uow.Commit();
            }
        }
Ejemplo n.º 15
0
    public async Task GetCustomerUser()
    {
        var userSvc    = Container.Resolve <IUserAppService>();
        var customerId = new CustomerId();

        var userId = await userSvc.AddCustomerUserAsync(
            customerId,
            new EmailAddressDto("*****@*****.**")
            );

        var user = await userSvc.GetAsync(userId);

        var customerUser = user as CustomerUserDto;

        Assert.IsNotNull(user);
        Assert.IsNotNull(customerUser);
        Assert.AreEqual("*****@*****.**", customerUser !.Email?.Value);
        Assert.AreEqual(customerId, customerUser.CustomerId);
    }
Ejemplo n.º 16
0
        public async Task <CustomerDTO> GetAsync(CustomerId id)
        {
            var sqlParams = new
            {
                CustomerId = id.RawValue
            };
            string sql = @"
                SELECT C.Id,
                       C.DisplayName
                FROM dbo.Customers C
                WHERE Id = @CustomerId;
            ";

            return(await _db.Query(async (db) =>
            {
                var results = await db.FetchAsync <CustomerDTO>(sql, sqlParams);
                return results.SingleOrDefault();
            }));
        }
Ejemplo n.º 17
0
        public IActionResult ApplyCashWithdrawal([Required] CustomerIdDto customerId, [Required] decimal amount)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var cid = new CustomerId(customerId.Id);

            var customerInfo = _customerService.GetCustomerInfoFromId(cid);

            var operation = new OperationCashWithdrawal(customerInfo.MasterAccountId, amount);

            var operationResult = _accountService.ApplyOperation(operation);

            var dto = Map(operationResult);

            return(Ok(dto));
        }
Ejemplo n.º 18
0
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteElementString("OrderId", Id.ToString());
     writer.WriteStartElement("DateCreated");
     writer.WriteAttributeString("Kind", DateCreated.Kind.ToString());
     writer.WriteValue(DateCreated.ToString());
     writer.WriteEndElement();
     writer.WriteElementString("Description", Description);
     writer.WriteElementString("CustomerId", CustomerId.ToString());
     writer.WriteStartElement("OrderItems");
     foreach (var item in Items)
     {
         writer.WriteStartElement("OrderItem");
         writer.WriteElementString("ProductId", item.ProductId.ToString());
         writer.WriteElementString("Quantity", item.Quantity.ToString());
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
 }
Ejemplo n.º 19
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CustomerId.Length != 0)
            {
                hash ^= CustomerId.GetHashCode();
            }
            hash ^= operations_.GetHashCode();
            if (ResponseContentType != global::Google.Ads.GoogleAds.V5.Enums.ResponseContentTypeEnum.Types.ResponseContentType.Unspecified)
            {
                hash ^= ResponseContentType.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        /// <summary>
        /// Returns true if SessionResponse instances are equal
        /// </summary>
        /// <param name="other">Instance of SessionResponse to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(SessionResponse other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     AssetUrl == other.AssetUrl ||
                     AssetUrl != null &&
                     AssetUrl.Equals(other.AssetUrl)
                     ) &&
                 (
                     ClientApiUrl == other.ClientApiUrl ||
                     ClientApiUrl != null &&
                     ClientApiUrl.Equals(other.ClientApiUrl)
                 ) &&
                 (
                     ClientSessionId == other.ClientSessionId ||
                     ClientSessionId != null &&
                     ClientSessionId.Equals(other.ClientSessionId)
                 ) &&
                 (
                     CustomerId == other.CustomerId ||
                     CustomerId != null &&
                     CustomerId.Equals(other.CustomerId)
                 ) &&
                 (
                     InvalidTokens == other.InvalidTokens ||
                     InvalidTokens != null &&
                     InvalidTokens.SequenceEqual(other.InvalidTokens)
                 ) &&
                 (
                     Region == other.Region ||
                     Region != null &&
                     Region.Equals(other.Region)
                 ));
        }
Ejemplo n.º 21
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is Order other &&
                   ((Id == null && other.Id == null) || (Id?.Equals(other.Id) == true)) &&
                   ((LocationId == null && other.LocationId == null) || (LocationId?.Equals(other.LocationId) == true)) &&
                   ((ReferenceId == null && other.ReferenceId == null) || (ReferenceId?.Equals(other.ReferenceId) == true)) &&
                   ((Source == null && other.Source == null) || (Source?.Equals(other.Source) == true)) &&
                   ((CustomerId == null && other.CustomerId == null) || (CustomerId?.Equals(other.CustomerId) == true)) &&
                   ((LineItems == null && other.LineItems == null) || (LineItems?.Equals(other.LineItems) == true)) &&
                   ((Taxes == null && other.Taxes == null) || (Taxes?.Equals(other.Taxes) == true)) &&
                   ((Discounts == null && other.Discounts == null) || (Discounts?.Equals(other.Discounts) == true)) &&
                   ((ServiceCharges == null && other.ServiceCharges == null) || (ServiceCharges?.Equals(other.ServiceCharges) == true)) &&
                   ((Fulfillments == null && other.Fulfillments == null) || (Fulfillments?.Equals(other.Fulfillments) == true)) &&
                   ((Returns == null && other.Returns == null) || (Returns?.Equals(other.Returns) == true)) &&
                   ((ReturnAmounts == null && other.ReturnAmounts == null) || (ReturnAmounts?.Equals(other.ReturnAmounts) == true)) &&
                   ((NetAmounts == null && other.NetAmounts == null) || (NetAmounts?.Equals(other.NetAmounts) == true)) &&
                   ((RoundingAdjustment == null && other.RoundingAdjustment == null) || (RoundingAdjustment?.Equals(other.RoundingAdjustment) == true)) &&
                   ((Tenders == null && other.Tenders == null) || (Tenders?.Equals(other.Tenders) == true)) &&
                   ((Refunds == null && other.Refunds == null) || (Refunds?.Equals(other.Refunds) == true)) &&
                   ((Metadata == null && other.Metadata == null) || (Metadata?.Equals(other.Metadata) == true)) &&
                   ((CreatedAt == null && other.CreatedAt == null) || (CreatedAt?.Equals(other.CreatedAt) == true)) &&
                   ((UpdatedAt == null && other.UpdatedAt == null) || (UpdatedAt?.Equals(other.UpdatedAt) == true)) &&
                   ((ClosedAt == null && other.ClosedAt == null) || (ClosedAt?.Equals(other.ClosedAt) == true)) &&
                   ((State == null && other.State == null) || (State?.Equals(other.State) == true)) &&
                   ((Version == null && other.Version == null) || (Version?.Equals(other.Version) == true)) &&
                   ((TotalMoney == null && other.TotalMoney == null) || (TotalMoney?.Equals(other.TotalMoney) == true)) &&
                   ((TotalTaxMoney == null && other.TotalTaxMoney == null) || (TotalTaxMoney?.Equals(other.TotalTaxMoney) == true)) &&
                   ((TotalDiscountMoney == null && other.TotalDiscountMoney == null) || (TotalDiscountMoney?.Equals(other.TotalDiscountMoney) == true)) &&
                   ((TotalTipMoney == null && other.TotalTipMoney == null) || (TotalTipMoney?.Equals(other.TotalTipMoney) == true)) &&
                   ((TotalServiceChargeMoney == null && other.TotalServiceChargeMoney == null) || (TotalServiceChargeMoney?.Equals(other.TotalServiceChargeMoney) == true)) &&
                   ((PricingOptions == null && other.PricingOptions == null) || (PricingOptions?.Equals(other.PricingOptions) == true)) &&
                   ((Rewards == null && other.Rewards == null) || (Rewards?.Equals(other.Rewards) == true)));
        }
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            CustomerId.AssertNotEmpty(nameof(CustomerId));
            UserId.AssertNotEmpty(nameof(UserId));
            RoleId.AssertNotEmpty(nameof(RoleId));

            try
            {
                Partner.Customers[CustomerId].DirectoryRoles[RoleId].UserMembers[UserId].Delete();
                WriteObject(true);
            }
            catch (PSPartnerException ex)
            {
                throw new PSPartnerException("Error removing user " + UserId + "from role " + RoleId, ex);
            }
            finally
            {
            }
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is OrderFulfillmentRecipient other &&
                   ((CustomerId == null && other.CustomerId == null) || (CustomerId?.Equals(other.CustomerId) == true)) &&
                   ((DisplayName == null && other.DisplayName == null) || (DisplayName?.Equals(other.DisplayName) == true)) &&
                   ((EmailAddress == null && other.EmailAddress == null) || (EmailAddress?.Equals(other.EmailAddress) == true)) &&
                   ((PhoneNumber == null && other.PhoneNumber == null) || (PhoneNumber?.Equals(other.PhoneNumber) == true)) &&
                   ((Address == null && other.Address == null) || (Address?.Equals(other.Address) == true)));
        }
Ejemplo n.º 24
0
        public async Task <Customer> GetByIdAsync(CustomerId customerId)
        {
            CustomerEntity entity = await GetEntityById(customerId);

            if (entity is null)
            {
                return(null);
            }

            return(Customer.Rehydrate
                   (
                       CustomerId.From(entity.Id),
                       entity.Gender,
                       Name.From(entity.Firstname),
                       Name.From(entity.Lastname),
                       Birthdate.From(entity.Birthdate),
                       entity.Comment
                   ));
        }
Ejemplo n.º 25
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CustomerId.Length != 0)
            {
                hash ^= CustomerId.GetHashCode();
            }
            hash ^= operations_.GetHashCode();
            if (ValidateOnly != false)
            {
                hash ^= ValidateOnly.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 26
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is Payment other &&
                   ((Id == null && other.Id == null) || (Id?.Equals(other.Id) == true)) &&
                   ((CreatedAt == null && other.CreatedAt == null) || (CreatedAt?.Equals(other.CreatedAt) == true)) &&
                   ((UpdatedAt == null && other.UpdatedAt == null) || (UpdatedAt?.Equals(other.UpdatedAt) == true)) &&
                   ((AmountMoney == null && other.AmountMoney == null) || (AmountMoney?.Equals(other.AmountMoney) == true)) &&
                   ((TipMoney == null && other.TipMoney == null) || (TipMoney?.Equals(other.TipMoney) == true)) &&
                   ((TotalMoney == null && other.TotalMoney == null) || (TotalMoney?.Equals(other.TotalMoney) == true)) &&
                   ((AppFeeMoney == null && other.AppFeeMoney == null) || (AppFeeMoney?.Equals(other.AppFeeMoney) == true)) &&
                   ((ProcessingFee == null && other.ProcessingFee == null) || (ProcessingFee?.Equals(other.ProcessingFee) == true)) &&
                   ((RefundedMoney == null && other.RefundedMoney == null) || (RefundedMoney?.Equals(other.RefundedMoney) == true)) &&
                   ((Status == null && other.Status == null) || (Status?.Equals(other.Status) == true)) &&
                   ((DelayDuration == null && other.DelayDuration == null) || (DelayDuration?.Equals(other.DelayDuration) == true)) &&
                   ((DelayAction == null && other.DelayAction == null) || (DelayAction?.Equals(other.DelayAction) == true)) &&
                   ((DelayedUntil == null && other.DelayedUntil == null) || (DelayedUntil?.Equals(other.DelayedUntil) == true)) &&
                   ((SourceType == null && other.SourceType == null) || (SourceType?.Equals(other.SourceType) == true)) &&
                   ((CardDetails == null && other.CardDetails == null) || (CardDetails?.Equals(other.CardDetails) == true)) &&
                   ((LocationId == null && other.LocationId == null) || (LocationId?.Equals(other.LocationId) == true)) &&
                   ((OrderId == null && other.OrderId == null) || (OrderId?.Equals(other.OrderId) == true)) &&
                   ((ReferenceId == null && other.ReferenceId == null) || (ReferenceId?.Equals(other.ReferenceId) == true)) &&
                   ((CustomerId == null && other.CustomerId == null) || (CustomerId?.Equals(other.CustomerId) == true)) &&
                   ((EmployeeId == null && other.EmployeeId == null) || (EmployeeId?.Equals(other.EmployeeId) == true)) &&
                   ((RefundIds == null && other.RefundIds == null) || (RefundIds?.Equals(other.RefundIds) == true)) &&
                   ((RiskEvaluation == null && other.RiskEvaluation == null) || (RiskEvaluation?.Equals(other.RiskEvaluation) == true)) &&
                   ((BuyerEmailAddress == null && other.BuyerEmailAddress == null) || (BuyerEmailAddress?.Equals(other.BuyerEmailAddress) == true)) &&
                   ((BillingAddress == null && other.BillingAddress == null) || (BillingAddress?.Equals(other.BillingAddress) == true)) &&
                   ((ShippingAddress == null && other.ShippingAddress == null) || (ShippingAddress?.Equals(other.ShippingAddress) == true)) &&
                   ((Note == null && other.Note == null) || (Note?.Equals(other.Note) == true)) &&
                   ((StatementDescriptionIdentifier == null && other.StatementDescriptionIdentifier == null) || (StatementDescriptionIdentifier?.Equals(other.StatementDescriptionIdentifier) == true)) &&
                   ((ReceiptNumber == null && other.ReceiptNumber == null) || (ReceiptNumber?.Equals(other.ReceiptNumber) == true)) &&
                   ((ReceiptUrl == null && other.ReceiptUrl == null) || (ReceiptUrl?.Equals(other.ReceiptUrl) == true)));
        }
Ejemplo n.º 27
0
        public void CreateOrder_FindByCustomerId()
        {
            var customerId       = new CustomerId(Guid.NewGuid().ToString());
            var customerFullName = "Test Customer";
            var domain           = DefaultOrder(customerId, customerFullName);

            domain.AddOrderLine("Test Product", 1, 10.95m);

            Repository(repository => repository.Add(domain));

            Repository(repository =>
            {
                var q = new CustomerOrders {
                    CustomerId = customerId
                };
                var orders = repository.Search(q);
                Assert.AreEqual(1, orders.TotalFound);
            });
        }
        public void ItShouldReturnTrueWhenItsTryingToWriteFile()
        {
            //Arrange
            LoggingService logging  = new LoggingService();
            CustomerId     id       = new CustomerId("1111");
            CustomerName   name     = new CustomerName("customer");
            Customer       customer = Customer.SignUp(id, name);

            var changedItems = new List <ILoggable>
            {
                customer
            };

            //Act
            var result = logging.WriteToFile(changedItems, "C:\\Users\\Usuario\\Documents");

            //Assert
            Assert.AreEqual(result, true);
        }
        public async Task <ICustomer> GetBy(CustomerId customerId)
        {
            var customer = await _context.Customers
                           .Where(c => c.Id.Equals(customerId))
                           .SingleOrDefaultAsync();

            if (customer is null)
            {
                throw new CustomerNotFoundException($"The customer {customerId} does not exist or is not processed yet.");
            }

            var accounts = _context.Accounts
                           .Where(e => e.CustomerId.Equals(customer.Id))
                           .Select(e => e.Id)
                           .ToList();

            customer.LoadAccounts(accounts);

            return(customer);
        }
Ejemplo n.º 30
0
        public SalesOrder(IDomainEventRaiser observer, CustomerId customer, RefWarehouseId warehouse)
        {
            _observer = observer;

            if (customer == null)
            {
                throw new Exception("Customer id cannot be null");
            }
            if (warehouse == null)
            {
                throw new Exception("Warehouse id cannot be null");
            }

            Id         = new SalesOrderId(Guid.NewGuid());
            Customer   = customer;
            _warehouse = warehouse;

            Status = Status.CreateOpened();
            Lines  = new Lines(Id, ref _status);
        }
Ejemplo n.º 31
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CustomerId.Length != 0)
            {
                hash ^= CustomerId.GetHashCode();
            }
            hash ^= operations_.GetHashCode();
            if (metadataCase_ == MetadataOneofCase.CustomerMatchUserListMetadata)
            {
                hash ^= CustomerMatchUserListMetadata.GetHashCode();
            }
            hash ^= (int)metadataCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Create a new customer from the parameters. If not valid, return null
        /// </summary>
        public static Customer Create(CustomerId id, PersonalName name, EmailAddress email)
        {
            if (id == null)
            {
                return(null);
            }
            if (name == null)
            {
                return(null);
            }
            if (email == null)
            {
                return(null);
            }

            // Compare this with the F# version, where the domain object
            // doesn't need to check for nulls

            return(new Customer(id, name, email));
        }
Ejemplo n.º 33
0
        // override object.Equals
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            var compareObj = (UserCustomerInfo)obj;

            if (UserId.CompareTo(compareObj.UserId) != 0)
            {
                return(false);
            }
            if (CustomerId.CompareTo(compareObj.CustomerId) != 0)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 34
0
 public void PrintOrders(CustomerId customerId)
 {
     var orderIds = _orderService.GetOrders(customerId);
     _orderPrinter.PrintOrders(orderIds);
 }
Ejemplo n.º 35
0
 public bool Equals(CustomerId other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.Value == Value;
 }
Ejemplo n.º 36
0
        public SessionIdentity(
            UserId user,
            SecurityId customer,
            string userName,
            string cookieString,
            IEnumerable<string> permissions,
            string token)
        {
            User = user;
            Security = customer;
            UserName = userName;
            SessionDisplay = String.Format("{0} ({1})", UserName, customer.Id);

            CookieString = cookieString;
            Customer = new CustomerId(customer.Id);
            Permissions = new HashSet<string>(permissions);
            Token = token;
        }
 public Customer(CustomerId id, string name)
 {
     this.Id = id;
     this.Name = name;
 }
 /// <summary>
 /// Client with dependency injection
 /// </summary>
 public static Customer Client(Func<CustomerId, Customer> customerRepository)
 {
     var id = new CustomerId(1);
     return customerRepository(id);
 }
Ejemplo n.º 39
0
 public CustomerCreated(CustomerId id, string name, string adress)
 {
     Id = id;
     Name = name;
     Adress = adress;
 }