Example #1
0
        public IHttpActionResult CreateMember(coreModel.Member member)
        {
            _memberService.CreateOrUpdate(new [] { member });
            var retVal = _memberService.GetByIds(new[] { member.Id }).FirstOrDefault();

            return(Ok(retVal));
        }
Example #2
0
        public static dataModel.Member ToDataModel(this coreModel.Member member, dataModel.Member dbEntity)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            dbEntity.InjectFrom(member);

            if (member.Phones != null)
            {
                dbEntity.Phones = new ObservableCollection <dataModel.Phone>(member.Phones.Select(x => new dataModel.Phone
                {
                    Number   = x,
                    MemberId = member.Id
                }));
            }

            if (member.Emails != null)
            {
                dbEntity.Emails = new ObservableCollection <dataModel.Email>(member.Emails.Select(x => new dataModel.Email
                {
                    Address  = x,
                    MemberId = member.Id
                }));
            }

            if (member.Addresses != null)
            {
                dbEntity.Addresses = new ObservableCollection <dataModel.Address>(member.Addresses.Select(x => x.ToDataModel()));
                foreach (var address in dbEntity.Addresses)
                {
                    address.MemberId = member.Id;
                }
            }

            if (member.Notes != null)
            {
                dbEntity.Notes = new ObservableCollection <dataModel.Note>(member.Notes.Select(x => x.ToDataModel()));
                foreach (var note in dbEntity.Notes)
                {
                    note.MemberId = member.Id;
                }
            }
            return(dbEntity);
        }
Example #3
0
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="dbEntity"></param>
        /// <returns></returns>
        public static coreModel.Member ToCoreModel(this dataModel.Member dbEntity, coreModel.Member member)
        {
            if (dbEntity == null)
            {
                throw new ArgumentNullException("dbEntity");
            }
            var memberType = member.MemberType;

            member.InjectFrom(dbEntity);
            member.MemberType = memberType;

            member.Addresses = dbEntity.Addresses.OrderBy(x => x.Id).Select(x => x.ToCoreModel()).ToList();
            member.Emails    = dbEntity.Emails.OrderBy(x => x.Id).Select(x => x.Address).ToList();
            member.Notes     = dbEntity.Notes.OrderBy(x => x.Id).Select(x => x.ToCoreModel()).ToList();
            member.Phones    = dbEntity.Phones.OrderBy(x => x.Id).Select(x => x.Number).ToList();
            return(member);
        }
Example #4
0
 public IHttpActionResult UpdateMember(coreModel.Member member)
 {
     _memberService.CreateOrUpdate(new[] { member });
     return(StatusCode(HttpStatusCode.NoContent));
 }
		public MemberChangingEvent(EntryState state, Member member)
		{
			ChangeState = state;
            Member = member;
		}
Example #6
0
        public static GetTaxRequest ToAvaTaxAdjustmentRequest(this VirtoCommerce.Domain.Order.Model.CustomerOrder modifiedOrder, string companyCode, Member member, VirtoCommerce.Domain.Order.Model.CustomerOrder originalOrder, bool commit = false)
        {
            if (modifiedOrder.Addresses != null && modifiedOrder.Addresses.Any() && originalOrder.Items != null && originalOrder.Items.Any())
            {
                // Document Level Elements
                // Required Request Parameters
                var getTaxRequest = new GetTaxRequest
                {
                    CustomerCode = modifiedOrder.CustomerId,
                    DocDate = DateTime.UtcNow.ToString("yyyy-MM-dd"),
                    CompanyCode = companyCode,
                    Client = "VirtoCommerce,2.x,VirtoCommerce",
                    DocCode = string.Format("{0}.{1}", originalOrder.Number, DateTime.UtcNow.ToString("yy-MM-dd-hh-mm")),
                    DetailLevel = DetailLevel.Tax,
                    Commit = commit,
                    DocType = DocType.ReturnInvoice,
                    TaxOverride = new TaxOverrideDef
                    {
                        TaxOverrideType = "TaxDate",
                        Reason = "Adjustment for return",
                        TaxDate = originalOrder.CreatedDate == DateTime.MinValue
                            ? DateTime.UtcNow.ToString("yyyy-MM-dd")
                            : originalOrder.CreatedDate.ToString("yyyy-MM-dd"),
                        TaxAmount = "0"
                    }
                };

                // Best Practice Request Parameters

                // Situational Request Parameters
                // getTaxRequest.CustomerUsageType = "G";
                // getTaxRequest.ExemptionNo = "12345";
                // getTaxRequest.BusinessIdentificationNo = "234243"; //for VAT tax calculations
                // getTaxRequest.Discount = 50;

                // Optional Request Parameters
                //getTaxRequest.PurchaseOrderNo = order.Number;
                getTaxRequest.ReferenceCode = originalOrder.Number;
                //getTaxRequest.PosLaneCode = "09";
                getTaxRequest.CurrencyCode = modifiedOrder.Currency.ToString();

                //add customer tax exemption code to cart if exists
                getTaxRequest.ExemptionNo = member.GetDynamicPropertyValue("Tax exempt", string.Empty);

                string destinationAddressIndex = "0";

                // Address Data
                var addresses = new List<Address>();

                foreach (var address in modifiedOrder.Addresses.Select((x, i) => new { Value = x, Index = i }))
                {
                    addresses.Add(new Address
                    {
                        AddressCode = address.Index.ToString(CultureInfo.InvariantCulture),
                        Line1 = address.Value.Line1,
                        City = address.Value.City,
                        Region = address.Value.RegionName ?? address.Value.RegionId,
                        PostalCode = address.Value.PostalCode,
                        Country = address.Value.CountryName
                    });

                    if (address.Value.AddressType == AddressType.Shipping
                        || address.Value.AddressType == AddressType.Shipping)
                        destinationAddressIndex = address.Index.ToString(CultureInfo.InvariantCulture);
                }

                getTaxRequest.Addresses = addresses.ToArray();

                // Line Data
                // Required Parameters

                getTaxRequest.Lines = originalOrder.Items.Where(i => !modifiedOrder.Items.Any(mli => mli.Id.Equals(i.Id)) || i.Quantity > (modifiedOrder.Items.Single(oi => oi.Id.Equals(i.Id)).Quantity)).Select(li =>
                    new Line
                    {
                        LineNo = li.Id,
                        ItemCode = li.ProductId,
                        Qty = modifiedOrder.Items.Any(mli => mli.Id.Equals(li.Id)) ? Math.Abs(li.Quantity - modifiedOrder.Items.Single(oi => oi.Id.Equals(li.Id)).Quantity) : li.Quantity,
                        Amount = modifiedOrder.Items.Any(mli => mli.Id.Equals(li.Id)) ? -(li.Price * li.Quantity - modifiedOrder.Items.Single(oi => oi.Id.Equals(li.Id)).Price * modifiedOrder.Items.Single(mli => mli.Id.Equals(li.Id)).Quantity) : -li.Price * li.Quantity,
                        OriginCode = destinationAddressIndex, //TODO set origin address (fulfillment?)
                        DestinationCode = destinationAddressIndex,
                        Description = li.Name,
                        TaxCode = li.TaxType
                    }
                    ).ToList();

                return getTaxRequest;
            }
            return null;
        }