public static ReturnJasonConstruct <DTO.Address> Create(DTO.Address dto) { ReturnJasonConstruct <DTO.Address> obj = new ReturnJasonConstruct <DTO.Address>(); try { MissFreshEntities db = new MissFreshEntities(); if (db.Addresses.Count(p => p.accountId == dto.accountId) == maxAddressCount) { obj.SetWarningInformation("您的地址数不能超过6个,请删除其他地址来添加地址信息"); return(obj); } if (dto.defaultAddress == true)//Need set other address to undefault { StaticSetAddressUndefault(ref db, dto.accountId); } Models.Address model = dto.ToModel(); model.id = Guid.NewGuid(); db.Addresses.Add(model); db.SaveChanges(); obj.SetDTOObject(model.ToDTO()); } catch (Exception ex) { obj.SetFailedInformation(ex.Message, null); return(obj); } return(obj); }
public bool CreateNewUserAddress(int userID, string userAddress) { Address address = new Address(); address.UserID = userID; address.UserAddress = userAddress; Response<Address> response = address.Create(); return response.Success; }
public static MvcHtmlString LocationFor(this HtmlHelper htmlHelper, Address address) { string adr = address.BuildingName + "<br/>" + (address.AddressLine1.HasValue() ? (address.AddressLine1 + "<br/>") : "") + (address.AddressLine2.HasValue() ? (address.AddressLine2 + "<br/>") : "") + (address.AddressLine3.HasValue() ? (address.AddressLine3 + "<br/>") : "") + (address.City.HasValue() ? (address.City) : "") + (address.County.HasValue() ? (" (" + address.County + ")") : "") + ((!address.City.HasValue() && !address.County.HasValue()) ? "" : ", ") + (address.State.HasValue() ? (address.State + " ") : "") + (address.PostalCode.HasValue() ? (address.PostalCode + " ") : ""); return MvcHtmlString.Create(adr); }
public ActionResult Create(Address address) { try { Bus.Instance.GetEndpoint(new Uri("rabbitmq://localhost/demo/member-service")) .Send(new SaveMemberAddressMessage { CommandId = NewId.NextGuid(), Timestamp = DateTime.UtcNow, MemberId = address.MemberId, Street = address.Street, City = address.City, State = address.State, Zip = address.Zip, }); return RedirectToAction("Index"); } catch { return View(); } }
public bool ProcessOrder(List<PartOrder> partOrders, string phoneNr, string address) { //Create the user to be inserted into the database. UserDB userDB = new UserDB(); User user = userDB.GetUserByPhone(phoneNr); //if the user does not exist already, create one. if (user == null) { user = new User(); user.PhoneNumber = phoneNr; user.RankID = 0; user.Create(); } //Create the address to be inserted into the database. AddressDB addressDB = new AddressDB(); Address userAddress = addressDB.GetByAddress(address); //if the address does not exist already, create one. if (userAddress == null) { userAddress = new Address(); userAddress.UserAddress = address; userAddress.UserID = user.ID; userAddress.Create(); } //Create the order to be inserted to the database Order order = new Order(); order.AddressID = userAddress.ID; order.UserID = user.ID; order.StatusID = OrderStatus.WAITING; order.Create(); //The partorders are inserted to the database PartOrderDB poDB = new PartOrderDB(); //For debugging Part Orders when something happens. CustomHandlers.DatabaseLibrary.Response<PartOrder> r = poDB.CreateBatch(order.ID, partOrders); foreach (string s in r.Messages) { Console.WriteLine(s); } return r.Success; }