Ejemplo n.º 1
0
 public void AddorderAddress(orderAddressInfo shipinfo)
 {
     shipinfo.IsDefault = false;
     shipinfo.IsQuick   = false;
     if ((
             from a in context.orderAddressInfo
             where a.UserId == shipinfo.UserId
             select a).Count() >= 20)
     {
         throw new HimallException("账单地址最多最能创建20个!");
     }
     context.orderAddressInfo.Add(shipinfo);
     context.SaveChanges();
     SetDefaultorderAddress(shipinfo.Id, shipinfo.UserId);
 }
Ejemplo n.º 2
0
        public orderAddressInfo GetDefaultUserorderAddressByUserId(long userId)
        {
            orderAddressInfo regionFullName = context.orderAddressInfo.FirstOrDefault((orderAddressInfo item) => item.UserId == userId && item.IsDefault) ?? (
                from item in context.orderAddressInfo
                where item.UserId == userId
                orderby item.Id descending
                select item).FirstOrDefault();

            if (regionFullName != null)
            {
                IRegionService create = Instance <IRegionService> .Create;
                regionFullName.RegionFullName = create.GetRegionFullName(regionFullName.RegionId, " ");
                regionFullName.RegionIdPath   = create.GetRegionIdPath(regionFullName.RegionId);
            }
            return(regionFullName);
        }
Ejemplo n.º 3
0
        public void UpdateorderAddress(orderAddressInfo shipinfo)
        {
            orderAddressInfo phone = (
                from a in context.orderAddressInfo
                where a.Id == shipinfo.Id && a.UserId == shipinfo.UserId
                select a).FirstOrDefault();

            if (phone == null)
            {
                throw new HimallException("该账单地址不存在或已被删除!");
            }
            phone.Phone    = shipinfo.Phone;
            phone.RegionId = shipinfo.RegionId;
            phone.ShipTo   = shipinfo.ShipTo;
            phone.Address  = shipinfo.Address;
            phone.PostCode = shipinfo.PostCode;

            context.SaveChanges();
        }
Ejemplo n.º 4
0
 public JsonResult EditorderAddress(orderAddressInfo info)
 {
     info.UserId = base.CurrentUser.Id;
     ServiceHelper.Create <IorderAddressService>().UpdateorderAddress(info);
     return(Json(new { success = true, msg = "修改成功", id = info.Id }));
 }