public object AddBoxToBasket(int BoxID) { object JsonData = null; var box = _bs.GetBoxById(BoxID); var selectedBox = ((List <OrderDetailDTO>)HttpContext.Current.Session["cartDetails"]).Where(x => x.BoxID == BoxID).FirstOrDefault(); //Sepette verilen id ye göre olan kutu getirilir if (selectedBox != null) //O kutu sepete atıldıysa işlem yapılmaz { JsonData = new { message = " isimli ürün mevcut sayı arttırmak ıcın sepetinize gidiniz", box = box.Result.BoxName }; } else //Sepette o kutu yoksa yeni bir OrderDetail oluşturularak bilgileri alınır. { var orderDetail = new OrderDetailDTO() { BoxID = box.Result.ID, BoxName = box.Result.BoxName, UnitPrice = box.Result.Price, ImageUrl = box.Result.ImageUrl, OrderDate = DateTime.Now }; ((List <OrderDetailDTO>)HttpContext.Current.Session["cartDetails"]).Add(orderDetail); JsonData = new { message = " isimli ürün sepete başarıyla eklenmiştir", box = box.Result.BoxName }; } return(JsonData); }
public void UpdateCargo(int id, OrderDetailDTO orderDetailDTO) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var orderDetailInDB = _db.Order_Details.FirstOrDefault(x => x.ID == id); if (orderDetailInDB != null) { Mapper.Map <OrderDetailDTO, Order_Detail>(orderDetailDTO, orderDetailInDB); //varolan bir obje varsa 2.bir arguman olarak buraya verebiliriz. //yukardaki satir sayesinde bu islem otomatik saglandi ve gerek kalmadi. //orderDetailInDB.TotalPrice = orderDetailDTO.TotalPrice; //orderDetailInDB.Quantity = orderDetailDTO.Quantity; //orderDetailInDB.Product.ProductName = orderDetailDTO.Product.ProductName; //orderDetailInDB.Shipper.CompanyName = orderDetailDTO.Shipper.CompanyName; //orderDetailInDB.Customer.Address= orderDetailDTO.Customer.Address; //orderDetailInDB.Customer.FirstName= orderDetailDTO.Customer.FirstName; //orderDetailInDB.Customer.LastName= orderDetailDTO.Customer.LastName; _db.SaveChanges(); } }
public void AddOrder(OrderDetailDTO product, string username, bool isBasket) { var user = _userService.GetUserEntityByName(username); var order = new OrderDTO() { Id = Guid.NewGuid().ToString(), Date = DateTime.UtcNow, IsConfirmed = !isBasket, CustomerId = user.Id.ToString() }; var productOrder = product; var orderDetailEntity = Mapper.Map <OrderDetail>(productOrder); orderDetailEntity = (OrderDetail)_dtoToDomain.AddEntities(orderDetailEntity, productOrder); var orderEntity = Mapper.Map <Order>(order); orderEntity.User = user; orderEntity.OrderDetails = new List <OrderDetail> { orderDetailEntity }; _unitOfWork.Repository <Order>().Add(orderEntity); }
/// <summary> /// Lấy ra chi tiết đơn hàng /// </summary> /// <param name="OrderCode"></param> /// <returns></returns> public async Task <OrderDetailDTO> GetOrderDetailByOrderCode(string OrderCode) { OrderDetailDTO output = new OrderDetailDTO(); try { var jwt = _httpContextAccessor.HttpContext.User.FindFirst(p => p.Type == "access_token").Value; if (jwt != null) { _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwt); string apiUrl = $"/api/v1/Payment/GetOrderDetailByOrderCode"; string paramRequest = $"?OrderCode={OrderCode}"; var response = await _client.GetAsync(apiUrl + paramRequest); if (response.IsSuccessStatusCode) { string responseStream = await response.Content.ReadAsStringAsync(); output = JsonConvert.DeserializeObject <OrderDetailDTO>(responseStream); } } } catch (Exception e) { } return(output); }
public void ChangeItems(IEnumerable <OrderDetailDTO> changeItems, IEnumerable <OrderDetailDTO> newItems, IEnumerable <OrderDetailDTO> removeItems) { OrderDetailDTO change = null; this.Details = this.Details .Select(o => { change = changeItems.FirstOrDefault(c => c.ItemName.Equals(c.ItemName)); return(change ?? new OrderDetailDTO { ItemName = o.ItemName, Quntity = o.Quntaty, Price = o.Price }); }) .Except(newItems) .Union(removeItems) .Select(o => new OrderDetail(o.ItemName, o.Quntity, o.Price)); this.PushEvent(new OrderChangedEvent( this.Id, 1, this.Details.Select(o => new SharedKernel.IntegrationEvents.Orders.OrderDetailEventModel { ItemName = o.ItemName, Quntaty = o.Quntaty, Price = o.Price }) )); }
public void AddNewOrderDetails_ExistedOrder_GetCalled() { var fakeOrderDetailsDto = new OrderDetailDTO() { Id = Guid.NewGuid(), GameId = _fakeGameId }; var fakeOrderDetail = _mapper.Map <OrderDetail>(fakeOrderDetailsDto); var order = new Order() { Id = Guid.NewGuid(), OrderDetails = new List <OrderDetail>() { fakeOrderDetail } }; var orders = new List <Order>() { order }; _uow.Setup(uow => uow.Games.GetById(_fakeGameId)).Returns(_fakeGame); _uow.Setup(uow => uow.Orders.Get(It.IsAny <Func <Order, bool> >())).Returns(orders); _sut.AddNewOrderDetails(_fakeUserId, _fakeGameId); _uow.Verify(uow => uow.Orders.Get(It.IsAny <Func <Order, bool> >()), Times.Once); }
//convert item properties from string type to correct type in DTO private List <OrderDetailDTO> ConvertToDto(List <string> orderDetailStrings) { List <OrderDetailDTO> orderDetailDTOs = new List <OrderDetailDTO>(); int totalProperty = 16; for (int i = 0; i < (orderDetailStrings.Count / totalProperty); i++) { OrderDetailDTO orderDetail = new OrderDetailDTO(); orderDetail.Id = int.Parse(orderDetailStrings[0 + (i * totalProperty)]); orderDetail.OrderId = int.Parse(orderDetailStrings[1 + (i * totalProperty)]); orderDetail.RowVersion = orderDetailStrings[2 + (i * totalProperty)]; orderDetail.ReviseQuantity = decimal.Parse(orderDetailStrings[3 + (i * totalProperty)]); orderDetail.ItemNumber = orderDetailStrings[4 + (i * totalProperty)]; orderDetail.Description = orderDetailStrings[5 + (i * totalProperty)]; orderDetail.Tariff = orderDetailStrings[6 + (i * totalProperty)]; orderDetail.Quantity = decimal.Parse(orderDetailStrings[7 + (i * totalProperty)]); orderDetail.Cartons = float.Parse(orderDetailStrings[8 + (i * totalProperty)]); orderDetail.Cube = float.Parse(orderDetailStrings[9 + (i * totalProperty)]); orderDetail.KGS = float.Parse(orderDetailStrings[10 + (i * totalProperty)]); orderDetail.UnitPrice = float.Parse(orderDetailStrings[11 + (i * totalProperty)]); orderDetail.RetailPrice = float.Parse(orderDetailStrings[12 + (i * totalProperty)]); orderDetail.Warehouse = orderDetailStrings[13 + (i * totalProperty)]; orderDetail.Size = orderDetailStrings[14 + (i * totalProperty)]; orderDetail.Colour = orderDetailStrings[15 + (i * totalProperty)]; orderDetail.Status = OrderStatus.AwaitingBooking; orderDetailDTOs.Add(orderDetail); } return(orderDetailDTOs); }
/// <summary> /// Cập nhật quy mô gian hàng /// </summary> /// <param name="UpgrageBrandPackageDTO"></param> /// <returns></returns> public async Task <OrderDetailDTO> UpgradePackageBrand(UpgrageBrandPackageDTO UpgrageBrandPackageDTO) { OrderDetailDTO output = new OrderDetailDTO(); var jwt = _httpContextAccessor.HttpContext.User.FindFirst(p => p.Type == "access_token").Value; if (jwt != null) { _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwt); string apiUrl = $"/api/v1/Payment/UpgradePackageBrand"; var userInfo = JsonConvert.DeserializeObject <SumProfileResponseDTO>(_httpContextAccessor.HttpContext.User.FindFirst(p => p.Type == "UserInfomation").Value); UpgrageBrandPackageDTO.ProductBrandId = userInfo.ProductBrandId; UpgrageBrandPackageDTO.UserId = userInfo.UserId; var json = JsonConvert.SerializeObject(UpgrageBrandPackageDTO, Formatting.Indented); var stringContent = new StringContent(json, Encoding.UTF8, "application/json"); var response = await _client.PostAsync(apiUrl, stringContent); if (response.IsSuccessStatusCode) { string responseStream = await response.Content.ReadAsStringAsync(); output = JsonConvert.DeserializeObject <OrderDetailDTO>(responseStream); } } return(output); }
public void TestDtoToOrder() { OrderDetailDTO detailDto = new OrderDetailDTO() { Id = 1, QuantityInUnits = 123, UnitPrice = 213, ProductId = 1, ProductName = "FAkeProduct", Version = 1 }; OrderDTO dto = new OrderDTO() { Id = 1, OrderStatus = OrderStatus.Ordered, OrderDate = DateTime.Now, ShippedDate = null, CustomerId = 123, CustomerName = "Fakecustomer" }; dto.Details.Add(detailDto); Assert.AreEqual(true, dto.IsValid); Assert.AreEqual(true, detailDto.IsValid); Order order = OrderAdapter.DtoToOrder(dto); Assert.AreEqual <int>(dto.Id, order.OrderId); Assert.AreEqual <int>((int)dto.OrderStatus, (int)order.OrderStatus); Assert.AreEqual <DateTime?>(dto.OrderDate, order.OrderDate); Assert.AreEqual <DateTime?>(dto.ShippedDate, order.ShippedDate); Assert.AreEqual <int>(dto.CustomerId, order.Customer.CustomerId); //TODO: Assert.AreEqual<string>(dto.CustomerName, order.Customer.Username); Assert.AreEqual(dto.Version, order.Version); //TODO: Assert.AreEqual<int>(dto.Details.Count(), order.Details.Count()); Assert.AreEqual(true, order.IsValid); }
public void TestOrderDetailModel() { OrderDetailDTO detailDto = new OrderDetailDTO() { Id = 1, QuantityInUnits = 123, UnitPrice = 213, ProductId = 1, ProductName = "FAkeProduct", Version = 1 }; OrderDTO dto = new OrderDTO() { Id = 1, OrderStatus = OrderStatus.Ordered, OrderDate = DateTime.Now, ShippedDate = null, CustomerId = 123, CustomerName = "Fakecustomer" }; dto.Details.Add(detailDto); OrderDetailViewModel orderDetailViewModel = new OrderDetailViewModel(dto, false); orderDetailViewModel.Service = serviceFacade; Expect.Once.On(serviceFacade).Method("StoreOrder").With(dto); orderDetailViewModel.SaveCommand.Command.Execute(null); Assert.AreEqual(dto, orderDetailViewModel.Model); Assert.AreEqual(Strings.OrderDetailViewModel_DisplayName, orderDetailViewModel.DisplayName); OrderItemViewModel detailListViewModel = (OrderItemViewModel)orderDetailViewModel.ListViewModel; Assert.AreEqual(detailDto, detailListViewModel.Items.FirstOrDefault()); }
public int AddOrderDetail(List <OrderDetailDTO> listorderDetailDTO) { int result = 1; SqlCommand cmd; for (int index = 0; index < listorderDetailDTO.Count; index++) { OrderDetailDTO orderDetail = new OrderDetailDTO(); orderDetail.IdOrder = listorderDetailDTO[index].IdOrder; orderDetail.IdProduct = listorderDetailDTO[index].IdProduct; orderDetail.Amount = listorderDetailDTO[index].Amount; orderDetail.idUnit = listorderDetailDTO[index].idUnit; orderDetail.idSuplier = listorderDetailDTO[index].idSuplier; cmd = new SqlCommand("USP_INSERT_ORDERDETAIL", _conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@nvcIdOrderProduct", orderDetail.IdOrder); cmd.Parameters.AddWithValue("@nvcIdProduct", orderDetail.IdProduct); cmd.Parameters.AddWithValue("@nvcAmount", orderDetail.Amount); cmd.Parameters.AddWithValue("@nvcIdUnit", orderDetail.idUnit); cmd.Parameters.AddWithValue("@nvcIdSuplier", orderDetail.idSuplier); _conn.Open(); int check = cmd.ExecuteNonQuery(); if (check != 1) { result = check; break; } _conn.Close(); } return(result); }
public bool createOrderDetail(OrderDetailDTO dto) { bool result = false; SqlConnection cnn = new SqlConnection(cs); string sql = "insert into [dbo].[tblOderDetail](orderID, bookID, price) values (@orderID,@bookID,@price)"; SqlCommand cmd = new SqlCommand(sql, cnn); cmd.Parameters.AddWithValue("@orderID", dto.orderID); cmd.Parameters.AddWithValue("@bookID", dto.bookID); cmd.Parameters.AddWithValue("@price", dto.price); try { if (cnn.State == ConnectionState.Closed) { cnn.Open(); } result = cmd.ExecuteNonQuery() > 0; } catch (SqlException ex) { throw new Exception(ex.Message); } finally { cnn.Close(); } return(result); }
public HttpResponseMessage CreateOrderLineItem(HttpRequestMessage request, [FromBody] OrderDetailDTO orderDTO) { OrdersApiModel ordersWebApiModel = new OrdersApiModel(); TransactionalInformation transaction = new TransactionalInformation(); OrdersBusinessService ordersBusinessService; ordersWebApiModel.IsAuthenicated = true; ordersBusinessService = new OrdersBusinessService(ordersDataService); OrderDetail orderDetail = ordersBusinessService.CreateOrderDetailLineItem( orderDTO.OrderID, orderDTO.ProductID, orderDTO.Quantity, out transaction); if (transaction.ReturnStatus == false) { ordersWebApiModel.ReturnMessage = transaction.ReturnMessage; ordersWebApiModel.ReturnStatus = transaction.ReturnStatus; ordersWebApiModel.ValidationErrors = transaction.ValidationErrors; var badResponse = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel); return(badResponse); } List <OrderDetails> orderDetails = ordersBusinessService.GetOrderDetails(orderDTO.OrderID, out transaction); if (transaction.ReturnStatus == false) { ordersWebApiModel.ReturnMessage = transaction.ReturnMessage; ordersWebApiModel.ReturnStatus = transaction.ReturnStatus; ordersWebApiModel.ValidationErrors = transaction.ValidationErrors; var badResponse = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel); return(badResponse); } Order order = ordersBusinessService.GetOrder(orderDTO.OrderID, out transaction); if (transaction.ReturnStatus == false) { ordersWebApiModel.ReturnMessage = transaction.ReturnMessage; ordersWebApiModel.ReturnStatus = transaction.ReturnStatus; ordersWebApiModel.ValidationErrors = transaction.ValidationErrors; var badResponse = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel); return(badResponse); } transaction.ReturnMessage.Add("Detail line item succcessfully added."); ordersWebApiModel.ReturnStatus = transaction.ReturnStatus; ordersWebApiModel.ReturnMessage = transaction.ReturnMessage; ordersWebApiModel.OrderDetails = orderDetails; ordersWebApiModel.Order = order; var response = Request.CreateResponse <OrdersApiModel>(HttpStatusCode.OK, ordersWebApiModel); return(response); }
private void Save() { var model = new OrderDetailDTO(); model.SupplierId = SelectedSupplier.Id; model.LocationId = this.locationId; model.OrderDate = DateTime.Now; model.AcceptDate = DateTime.Now; model.Accept = false; model.Products = Products.Where(x => !x.Value.Equals(0)).Select(x => new ProductOrderedDTO() { ProductId = x.ProductId, Value = x.Value, Price = x.Price, Tax = x.Tax }).ToList(); orderApi = new OrderAPI(); var resultFlag = orderApi.Create(model); if (resultFlag) { MessageBox.Show("Заказ создан"); } if (!resultFlag) { MessageBox.Show("Ошибка создания заказа"); } }
public void AddProductToOrder(int orderId, int productId, int quantity) { OrderDetailDTO orderDetail = _mapper.Map <OrderDetailDTO>(_unitOfWork.OrderDetaiRepository.FindByIds(productId, orderId)); if (orderDetail != null) { ChangeProductQuantity(orderId, productId, quantity); return; } Product pr = _unitOfWork.ProductRepository.GetById(productId); ProductDTO product = _mapper.Map <ProductDTO>(pr); if (product.AvailableQuantity >= quantity) { product.AvailableQuantity -= quantity; _mapper.Map <ProductDTO, Product>(product, pr); _unitOfWork.ProductRepository.Update(pr); OrderDetailDTO orderDetailDTO = new OrderDetailDTO() { OrderId = orderId, ProductId = productId, Quantity = quantity }; _unitOfWork.OrderDetaiRepository.Insert(_mapper.Map <OrderDetail>(orderDetailDTO)); _unitOfWork.Save(); } else { throw new InvalidOperationException("Not Enough Items"); } }
public OrderDetailModel ConvertToOrderDetailModel(OrderDetailDTO orderDetailDTO) { OrderDetailModel orderDetailModel = new OrderDetailModel(); orderDetailModel.Id = orderDetailDTO.Id; orderDetailModel.ItemNumber = orderDetailDTO.ItemNumber; orderDetailModel.Description = orderDetailDTO.Description; orderDetailModel.Tariff = orderDetailDTO.Tariff; orderDetailModel.Quantity = orderDetailDTO.Quantity; orderDetailModel.Cartons = orderDetailDTO.Cartons; orderDetailModel.Cube = orderDetailDTO.Cube; orderDetailModel.KGS = orderDetailDTO.KGS; orderDetailModel.UnitPrice = orderDetailDTO.UnitPrice; orderDetailModel.RetailPrice = orderDetailDTO.RetailPrice; orderDetailModel.Warehouse = orderDetailDTO.Warehouse; orderDetailModel.Size = orderDetailDTO.Size; orderDetailModel.Colour = orderDetailDTO.Colour; orderDetailModel.OrderId = orderDetailDTO.OrderId; if (orderDetailModel.OrderId == 0) { orderDetailModel.OrderId = db.GetDB().Orders.ToList().Last().Id; } orderDetailModel.Line = ""; orderDetailModel.Item = ""; return(orderDetailModel); }
public async Task <OrderDetailDTO> CreateOrUpdateOrderDetailAsync(OrderDetailDTO orderDetail) { OrderDetail entity; if (orderDetail.Id > 0) { entity = await _orderDetailRepository.GetByIdAsync(orderDetail.Id, false); if (entity == null) { throw new AppException("Purchase Order Detail Not Found"); } entity = Mapper.Map(orderDetail, entity); //entity = Mapper.Map<OrderDetail>(orderDetail); _orderDetailRepository.Update(entity); } else { entity = Mapper.Map <OrderDetail>(orderDetail); _orderDetailRepository.Insert(entity); } await UnitOfWork.SaveChangesAsync(); var rs = Mapper.Map <OrderDetailDTO>(entity); return(rs); }
public void CreateOrder(OrderDetailDTO order) { Order orderToCreate = new Order() { CustomerId = order.CustomerId, StoreId = order.StoreId, OrderDate = DateTime.Now, Subtotal = order.Subtotal }; _context.Add(orderToCreate); _context.SaveChanges(); Order justCreated = _context.Orders.OrderBy(x => x.OrderId).Last(); var deetsOfJustCreated = _context.OrderDetails.OrderBy(x => x.OrderId).Last(); List <OrderDetail> listOfDeets = new List <OrderDetail>(); foreach (var item in order.Products) { var moreInfo = new OrderDetail { OrderId = justCreated.OrderId, ProductId = item.ProductId, Quantity = item.Quantity }; listOfDeets.Add(moreInfo); } foreach (var deet in listOfDeets) { _context.Add(deet); _context.SaveChanges(); } }
public ActionResult OrderDetails(int id) { var ord = from o in _db.Order join c in _db.CustomerMsts on o.FK_CustomerId equals c.pk_Custid join p in _db.PaymentTypes on o.FK_PaymentTypeId equals p.pk_PaymentTypeId where o.OrderId == id select new { OrderId = o.OrderId, OrderNumber = o.OrderNumber, OrderDate = o.OrderDate, OrderStatus = o.OrderStatus, CustomerName = c.Name, FinalTotal = o.FinalTotal, PaymentType = p.PaymentType, OrderCancelDate = o.OrderCancelDate }; var dbOrder = ord.FirstOrDefault(); var order = new OrderDTO { OrderId = dbOrder.OrderId, OrderNumber = dbOrder.OrderNumber, OrderDate = dbOrder.OrderDate, OrderStatus = dbOrder.OrderStatus, OrderCancelDate = dbOrder.OrderCancelDate, CustomerName = dbOrder.CustomerName, FinalTotal = dbOrder.FinalTotal }; var orderDetails = from od in _db.OrderDetail.Where(a => a.FK_OrderId == order.OrderId) join pr in _db.ProductMsts on od.FK_ProductId equals pr.pk_ProductId select new { OrderDetailId = od.OrderDetailId, FK_OrderId = od.FK_OrderId, ProductName = pr.ProductName, FK_ProductId = od.FK_ProductId, UnitPrice = od.UnitPrice, Quantity = od.Quantity, Discount = od.Discount, Total = od.Total }; var orderDetailDTOs = new List <OrderDetailDTO>(); foreach (var o in orderDetails) { var orderDetailDTO = new OrderDetailDTO { OrderDetailId = o.OrderDetailId, FK_OrderId = o.FK_OrderId, ProductName = o.ProductName, FK_ProductId = o.FK_ProductId, UnitPrice = o.UnitPrice, Quantity = o.Quantity, Discount = o.Discount, Total = o.Total }; orderDetailDTOs.Add(orderDetailDTO); } order.OrderDetails = orderDetailDTOs; return(View("OrderDetail", order)); }
public int UpdateOrderDetail(OrderDetailDTO orderDetail) { string query = "UPDATE OrderDetail SET BookID = @bookID, PaymentID = @paymentID WHERE UserID = @userID"; List <SqlParameter> parameters = GetParametersOrderDetail(orderDetail); h.AddParametersToCommand(parameters); return(h.MyExecuteQuery(query)); }
/// <summary> /// The CopyFromOrderDetailsDTO /// </summary> /// <param name="orderDetailViewModel">The orderDetailViewModel<see cref="OrderDetailViewModel"/></param> /// <param name="orderDto">The orderDto<see cref="OrderDetailDTO"/></param> public static void CopyFromOrderDetailsDTO(this OrderDetailViewModel orderDetailViewModel, OrderDetailDTO orderDto) { orderDetailViewModel.OrderID = orderDto.OrderID; orderDetailViewModel.ProductID = orderDto.ProductID; orderDetailViewModel.Quantitty = orderDto.Quantitty; orderDetailViewModel.ProductName = orderDto.ProductName; }
public static OrderDetail ToOrderDetail(this OrderDetailDTO dto) { return(new OrderDetail { ProductId = dto.ProductId.Value, Quantity = dto.Quantity.Value, }); }
public int InsertOrderDetail(OrderDetailDTO orderDetail) { string query = "INSERT INTO OrderDetail(OrderID, BookID, PaymentID) VALUES(@orderID, @bookID, @paymentID)"; List <SqlParameter> parameters = GetParametersOrderDetail(orderDetail); h.AddParametersToCommand(parameters); return(h.MyExecuteQuery(query)); }
List <SqlParameter> GetParametersOrderDetail(OrderDetailDTO orderDetail) { List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("@orderID", orderDetail.OrderID)); parameters.Add(new SqlParameter("@bookID", orderDetail.BookID)); parameters.Add(new SqlParameter("@paymentID", orderDetail.PaymentID)); return(parameters); }
public int AddOrderDetail(OrderDetailDTO dto) { using (session.BeginTransaction()) { session.Save(dto); session.Transaction.Commit(); return(dto.OrderDetailId); } }
public int UpdateOrderDetail(OrderDetailDTO dto) { using (session.BeginTransaction()) { session.SaveOrUpdate(dto); session.Transaction.Commit(); return(1); } }
public OrderDetailDTO GetById(Guid merchantAccountId, Guid orderId) { var order = new OrderDAC().GetById(orderId); var merchantAccount = new MerchantAccountDAC().GetById(merchantAccountId); var pos = new POSDAC().GetById(merchantAccount.POSId.Value); if (order == null) { throw new CommonException(10000, Resources.订单不存在); } if (order.MerchantAccountId != merchantAccountId) { throw new CommonException(10000, Resources.只能查看自己的订单); } var coin = new CryptocurrencyDAC().GetById(order.CryptoId); var er = order.ExchangeRate; var cer = GetExchangeRate(merchantAccount.CountryId, order.FiatCurrency, coin); var iRate = ((cer - er) / er) * 100; var result = new OrderDetailDTO { Id = order.Id, OrderNo = order.OrderNo, OrderStatus = order.Status, Timestamp = order.Timestamp.ToUnixTime(), CryptoStatus = coin.Status, CryptoEnable = coin.Enable, CryptoCode = coin.Code, CryptoAmount = order.CryptoAmount.ToString(coin.DecimalPlace), FiatCurrency = order.FiatCurrency, FiatAmount = order.FiatAmount.ToString(2), Markup = order.Markup, ActualFiatAmount = order.ActualFiatAmount.ToString(2), TransactionFee = order.TransactionFee.ToString(coin.DecimalPlace), ActualCryptoAmount = order.ActualCryptoAmount.ToString(coin.DecimalPlace), UserAccount = order.UserAccountId.HasValue ? GetUserMastMaskedCellphone(order.UserAccountId.Value) : string.Empty, SN = pos.Sn, ExchangeRate = er.ToString(4), CurrentExchangeRate = cer.ToString(4), IncreaseRate = iRate > 0 ? $"+{iRate.ToString(2)}" : iRate.ToString(2) }; if (result.OrderStatus == OrderStatus.Refunded) { var refund = new RefundDAC().GetByOrderId(result.Id); if (refund?.Timestamp != null) { result.RefundTimestamp = refund.Timestamp.ToUnixTime(); } } return(result); }
public IHttpActionResult Get(Guid id) { OrderDetailDTO dto = _logic.Read(id); if (dto == null) { return(NotFound()); } return(Ok(dto)); }
public int DeleteOrderDetail(OrderDetailDTO dto) { using (session.BeginTransaction()) { OrderDetailDTO old = session.Get <OrderDetailDTO>(dto.OrderDetailId); session.Delete(old); session.Transaction.Commit(); return(1); } }
public IHttpActionResult AddOrderDetail(int id, OrderDetailDTO orderDetailDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Order order = orderService.AddOrderDetail(id, OrderDetailDTO.FromOrderDetailDTO(orderDetailDTO, id)); return(Ok(OrderDTO.ToOrderDTO(order))); }