Ejemplo n.º 1
0
        public static List <PaymentMethodOption> GetPaymentMethodOptions()
        {
            auctionEntities      = new AuctionSystemEntities();
            paymentMethodOptions = new List <PaymentMethodOption>();

            //Retrieve the paymentmethods into an array from paymentmethod table in database.
            payment_method[] PaymentOptions = auctionEntities.payment_method.ToArray();

            //To check if paymentoptions array is empty, if null return paymentmehods list.
            if (PaymentOptions == null)
            {
                return(paymentMethodOptions);
            }

            //If not null then loop through the items in array
            foreach (payment_method paymentOption in PaymentOptions)
            {
                PaymentMethodOption PaymentMethodOption = new PaymentMethodOption()
                {
                    PaymentMethod_ID = paymentOption.id,
                    Payment_Method   = paymentOption.payment_method1
                };
                paymentMethodOptions.Add(PaymentMethodOption);
            }
            return(paymentMethodOptions);
        }
        //get Product by product id
        public static Product GetProduct(int productId)
        {
            auctionEntities = new AuctionSystemEntities();
            Product product = new Product();
            // To retrieve product from database using productid
            var dBproduct = auctionEntities.products.Where(p => p.id == productId).FirstOrDefault();

            //To  check if product is null
            if (dBproduct == null)
            {
                return(product);
            }

            //if product is not null check if product is present in auction table
            var auctions = auctionEntities.auctions.Where(c => c.product_id == productId).ToList();

            //if auction is not null then retrieve current highest bid price of the product from auction table
            if (auctions.Count > 0)
            {
                var currentHighestBid = auctions.Max(p => p.bid_price);
                product.CurrentHighestBid = currentHighestBid;
            }

            product.ProductName        = dBproduct.product_Name;
            product.ProductDescription = dBproduct.product_description;
            product.ProductBidPrice    = dBproduct.product_bid_price;
            product.ProductBidTime     = dBproduct.product_bid_time.ToString(format);
            product.Status             = (dBproduct.product_bid_time < DateTime.Now && dBproduct.status_id == (int)StatusCode.Active) ? "Inactive" : dBproduct.customer_status.status;
            product.CustomerId         = dBproduct.customer_id;
            product.ProductId          = dBproduct.id;
            product.ProductTypeId      = dBproduct.product_type_id;
            product.MaxPrice           = dBproduct.max_price;

            return(product);
        }
Ejemplo n.º 3
0
        public static OrdersResponse GetCustomerOrders(int customerid)
        {
            OrdersResponse        ordersResponse  = new OrdersResponse();
            AuctionSystemEntities auctionEntities = new AuctionSystemEntities();

            var orders = auctionEntities.orders.Where(c => c.customer_id == customerid).ToList();

            if (orders == null)
            {
                ordersResponse.Fault = new Error {
                    Code = ErrorCodes.NoOrders, Message = "There are no orders for this customer"
                };
                return(ordersResponse);
            }

            ordersResponse.CustomerOrders = new List <Order>();

            foreach (order order in orders)
            {
                Order customerOrders = new Order();
                customerOrders.AuctionId          = order.auction_id;
                customerOrders.CustomerId         = order.customer_id;
                customerOrders.CustomerPaymentId  = order.customer_payment_id;
                customerOrders.OrderAmount        = order.order_amount;
                customerOrders.OrderDatetime      = order.order_datetime.ToString(format);
                customerOrders.OrderId            = order.id;
                customerOrders.Status             = order.customer_status.status;
                customerOrders.StatusReason       = order.status_reason.reason;
                customerOrders.ProductName        = order.auction.product.product_Name;
                customerOrders.ProductDescription = order.auction.product.product_description;
                ordersResponse.CustomerOrders.Add(customerOrders);
            }
            return(ordersResponse);
        }
        //To create the product
        public static ProductResponse CreateProduct(ProductRequest product)
        {
            //create product object
            product Product = new product();

            Product.customer_id         = product.CustomerId;
            Product.product_type_id     = product.ProductTypeId;
            Product.product_Name        = product.ProductName;
            Product.product_bid_price   = product.ProductBidPrice;
            Product.product_bid_time    = product.ProductBidTime;
            Product.product_description = product.ProductDescription;
            Product.status_id           = (int)StatusCode.Active;
            Product.status_reason_id    = (int)StatusReasonCode.ProductIsAvailable;

            auctionEntities = new AuctionSystemEntities();
            auctionEntities.products.Add(Product);
            auctionEntities.SaveChanges();

            //create productresponse object
            ProductResponse productResponse = new ProductResponse();

            CustomerProduct.product                    = new Product();
            CustomerProduct.product.CustomerId         = Product.customer_id;
            CustomerProduct.product.ProductTypeId      = Product.product_type_id;
            CustomerProduct.product.ProductBidPrice    = Product.product_bid_price;
            CustomerProduct.product.ProductBidTime     = Product.product_bid_time.ToString(format);
            CustomerProduct.product.ProductName        = product.ProductName;
            CustomerProduct.product.ProductDescription = Product.product_description;
            CustomerProduct.product.ProductId          = Product.id;
            //add productmodel object to productmodel list
            productResponse.Products = new List <Product>();
            productResponse.Products.Add(CustomerProduct.product);

            return(productResponse);
        }
        //To retrieve the product types
        public static ProductTypesResponse GetProductTypes()
        {
            ProductTypesResponse productTypesResponse = new ProductTypesResponse();

            auctionEntities = new AuctionSystemEntities();
            //retrieve producttypes from productTypes table in database to a list
            var dbProductTypes = auctionEntities.product_type.ToList();

            //if list is null set fault as no product types
            if (dbProductTypes == null)
            {
                productTypesResponse.Fault = new Error {
                    Code = ErrorCodes.NoProductTypes, Message = "There are no Products"
                };
                return(productTypesResponse);
            }

            productTypesResponse.ProductTypes = new List <ProductTypes>();
            //loop through each item in list
            foreach (product_type dbProductType in dbProductTypes)
            {
                //create new products object and set values for properties
                ProductTypes productType = new ProductTypes()
                {
                    ProductTypeId = dbProductType.id,
                    ProductType   = dbProductType.type
                };
                productTypesResponse.ProductTypes.Add(productType);
            }
            return(productTypesResponse);
        }
        //To update products details
        public static ProductResponse UpdateProduct(ProductRequest productRequest)
        {
            auctionEntities = new AuctionSystemEntities();
            //create new product response object
            ProductResponse productResponse = new ProductResponse();

            //retrieve products from product table with productid and customer id
            product dbproduct = auctionEntities.products.Where(c => c.id == productRequest.ProductID && c.customer_id == productRequest.CustomerId).FirstOrDefault();

            //if product is null
            if (dbproduct == null || dbproduct.product_bid_time <= DateTime.Now)
            {
                //set fault as no auctions for this product
                productResponse.Error = new Error {
                    Code = ErrorCodes.ProductUnavailable, Message = "This product is not available"
                };
                return(productResponse);
            }

            //if product is not null then update values for the product from CustomerProduct object
            dbproduct.customer_id         = productRequest.CustomerId;
            dbproduct.product_type_id     = productRequest.ProductTypeId;
            dbproduct.product_Name        = productRequest.ProductName;
            dbproduct.product_bid_price   = productRequest.ProductBidPrice;
            dbproduct.product_bid_time    = productRequest.ProductBidTime;
            dbproduct.product_description = productRequest.ProductDescription;
            dbproduct.status_id           = (int)StatusCode.Active;
            dbproduct.status_reason_id    = (int)StatusReasonCode.ProductIsAvailable;

            auctionEntities.SaveChanges();

            //create product model object and set updated values to the properties
            CustomerProduct.product                    = new Product();
            CustomerProduct.product.CustomerId         = dbproduct.customer_id;
            CustomerProduct.product.ProductTypeId      = dbproduct.product_type_id;
            CustomerProduct.product.ProductBidPrice    = dbproduct.product_bid_price;
            CustomerProduct.product.ProductBidTime     = dbproduct.product_bid_time.ToString(format);
            CustomerProduct.product.ProductName        = dbproduct.product_Name;
            CustomerProduct.product.ProductDescription = dbproduct.product_description;
            CustomerProduct.product.ProductId          = dbproduct.id;
            //add productmodel object to list
            productResponse.Products = new List <Product>();
            productResponse.Products.Add(CustomerProduct.product);
            return(productResponse);
        }
        //To retrieve products with customerid
        public static ProductResponse GetCustomerProducts(int customerId)
        {
            auctionEntities = new AuctionSystemEntities();
            ProductResponse productResponse = new ProductResponse();

            //retrieve products from product table with customerid
            product[] products = auctionEntities.products.Where(c => c.customer_id == customerId).ToArray();
            //if empty set fault
            if (products == null)
            {
                productResponse.Error = new Error {
                    Code = ErrorCodes.ProductsUnavailable, Message = "This customer does not have any products"
                };
                return(productResponse);
            }

            productResponse.Products = new List <Product>();
            //if array is not null then loop through each item in array
            foreach (product product in products)
            {
                CustomerProduct.product = new Product();

                var userAuction = auctionEntities.auctions.Where(c => c.product_id == product.id).ToList();
                if (userAuction.Count != 0)
                {
                    var currentHighestBid = userAuction.Max(p => p.bid_price);
                    CustomerProduct.product.CurrentHighestBid = currentHighestBid;
                }

                CustomerProduct.product.CustomerId         = product.customer_id;
                CustomerProduct.product.ProductTypeId      = product.product_type_id;
                CustomerProduct.product.ProductBidPrice    = product.product_bid_price;
                CustomerProduct.product.ProductBidTime     = product.product_bid_time.ToString(format);
                CustomerProduct.product.ProductName        = product.product_Name;
                CustomerProduct.product.ProductDescription = product.product_description;
                CustomerProduct.product.MaxPrice           = product.max_price;
                CustomerProduct.product.ProductId          = product.id;
                CustomerProduct.product.Status             = product.customer_status.status;
                CustomerProduct.product.StatusReason       = product.status_reason.reason;

                productResponse.Products.Add(CustomerProduct.product);
            }
            return(productResponse);
        }
Ejemplo n.º 8
0
        //To update customer bid
        public static AuctionResponse UpdateCustomerBid(Model.Message.Auction auctionRequest)
        {
            auctionEntities = new AuctionSystemEntities();
            AuctionResponse auctionResponse = new AuctionResponse();

            var dbAuction = auctionEntities.auctions.Where(c => c.customer_id == auctionRequest.CustomerId && c.id == auctionRequest.AuctionId).FirstOrDefault();

            if (dbAuction == null || dbAuction.bidstatus_id != (int)StatusCode.Active || auctionRequest.BidStatus == "Inactive")
            {
                auctionResponse.Error = new Error {
                    Code = ErrorCodes.NoAuctions, Message = "Auction unavailable"
                };
                return(auctionResponse);
            }

            var currentHighestBid = auctionEntities.auctions.Where(c => c.product_id == dbAuction.product_id).Max(p => p.bid_price);

            if (currentHighestBid >= auctionRequest.BidPrice)
            {
                auctionResponse.Error = new Error {
                    Code = ErrorCodes.InvalidBidPrice, Message = "Bid price should be more than current highest bid"
                };
                return(auctionResponse);
            }

            dbAuction.bid_price = auctionRequest.BidPrice;
            auctionEntities.SaveChanges();

            auctionResponse.Auctions = new List <Model.Message.Auction>();
            Model.Message.Auction auction = new Model.Message.Auction()
            {
                AuctionId              = dbAuction.id,
                BidStatus              = dbAuction.bid_status.status,
                BidStatusReason        = dbAuction.bid_status_reason.status_reason,
                BidPrice               = dbAuction.bid_price,
                CurrentHighestBidPrice = currentHighestBid,
                CustomerId             = dbAuction.customer_id,
                ProductDescription     = dbAuction.product.product_description,
                ProductName            = dbAuction.product.product_Name,
                ProductId              = dbAuction.product_id
            };
            auctionResponse.Auctions.Add(auction);
            return(auctionResponse);
        }
Ejemplo n.º 9
0
        public static LoginModelResponse Login(LoginModelRequest login)
        {
            auctionEntities = new AuctionSystemEntities();
            loginResponse   = new LoginModelResponse();
            //To retrive customers based on email.
            customer customer = auctionEntities.customers.Where(c => c.customer_email == login.Email).FirstOrDefault();

            //check if customer already exist or not
            if (customer == null)
            {
                //if customer do not exist set fault as invalid email
                loginResponse.Error = new Error {
                    Code = ErrorCodes.InvalidEmail, Message = "User Email does not exist"
                };
                loginResponse.LoginIsValid = false;
                return(loginResponse);
            }
            //if customer exists check if passwords match by hashing the password
            if (customer.customer_password != CustomerRegistration.HashPassword(login.Password))
            {
                //if paswords do not match set fault as invalid password
                loginResponse.Error = new Error {
                    Code = ErrorCodes.InvalidPassword, Message = "User Email / Password does not match"
                };
                loginResponse.LoginIsValid = false;
                return(loginResponse);
            }

            //if passwords match login the user by setting loginresponse
            loginResponse.Email             = customer.customer_email;
            loginResponse.CustomerId        = customer.id;
            loginResponse.CustomerLastName  = customer.customer_lastname;
            loginResponse.CustomerFirstName = customer.customer_firstname;
            loginResponse.LoginIsValid      = true;

            return(loginResponse);
        }
        //To retrieve products with product type id
        public static ProductResponse GetProductsByProductTypeId(int productTypeId)
        {
            ProductResponse productResponse = new ProductResponse();

            auctionEntities = new AuctionSystemEntities();
            int status = (int)StatusCode.Active;

            //retrieve products from product table with producttypeid into array
            product[] dbProducts = auctionEntities.products.Where(c => c.product_type_id == productTypeId && c.status_id == status).ToArray();
            //if array is empty set fault as no products
            if (dbProducts == null)
            {
                productResponse.Error = new Error {
                    Code = ErrorCodes.ProductsUnavailable, Message = "There are no products in this category"
                };
                return(productResponse);
            }

            productResponse.Products = new List <Product>();
            //if array is not empty loop through each item in array
            foreach (product dbProduct in dbProducts)
            {
                product = new Product();
                product.ProductTypeId      = dbProduct.product_type_id;
                product.ProductBidPrice    = dbProduct.product_bid_price;
                product.ProductBidTime     = dbProduct.product_bid_time.ToString(format);
                product.ProductName        = dbProduct.product_Name;
                product.ProductDescription = dbProduct.product_description;
                product.MaxPrice           = dbProduct.max_price;
                product.ProductId          = dbProduct.id;
                product.Status             = dbProduct.customer_status.status;
                product.StatusReason       = dbProduct.status_reason.reason;

                productResponse.Products.Add(product);
            }
            return(productResponse);
        }
Ejemplo n.º 11
0
        //To retrieve customer order with orderid
        public static Order GetOrder(int orderid)
        {
            Order customerorder = new Order();
            AuctionSystemEntities auctionEntities = new AuctionSystemEntities();

            var order = auctionEntities.orders.Where(c => c.id == orderid).FirstOrDefault();

            if (order == null)
            {
                return(customerorder);
            }

            customerorder.OrderId            = order.id;
            customerorder.AuctionId          = order.auction_id;
            customerorder.CustomerId         = order.customer_id;
            customerorder.CustomerPaymentId  = order.customer_payment_id;
            customerorder.OrderAmount        = order.order_amount;
            customerorder.OrderDatetime      = order.order_datetime.ToString(format);
            customerorder.ProductName        = order.auction.product.product_Name;
            customerorder.ProductDescription = order.auction.product.product_description;
            customerorder.Status             = order.customer_status.status;
            customerorder.StatusReason       = order.status_reason.reason;
            return(customerorder);
        }
Ejemplo n.º 12
0
        //To get customerselected  bid
        public static Model.Message.Auction GetBid(int auctionid)
        {
            auctionEntities = new AuctionSystemEntities();
            Model.Message.Auction auction = new Model.Message.Auction();

            //retrieve auction from Auctions table with auctionid
            var dbAuction = auctionEntities.auctions.Where(c => c.id == auctionid).FirstOrDefault();

            //if auction is null set fault as no auctions
            if (dbAuction != null)
            {
                var highestBid = auctionEntities.auctions.Where(c => c.product_id == dbAuction.product_id).Max(p => p.bid_price);
                auction.AuctionId              = dbAuction.id;
                auction.ProductId              = dbAuction.product_id;
                auction.BidPrice               = dbAuction.bid_price;
                auction.ProductBidTime         = dbAuction.product.product_bid_time.ToString(format);
                auction.ProductName            = dbAuction.product.product_Name;
                auction.ProductDescription     = dbAuction.product.product_description;
                auction.BidStatus              = ((dbAuction.auction_datetime < DateTime.Now) && dbAuction.bidstatus_id == (int)BidStatusCode.Active) ? "Inactive" : dbAuction.bid_status.status;
                auction.BidStatusReason        = dbAuction.bid_status_reason.status_reason;
                auction.CurrentHighestBidPrice = highestBid;
            }
            return(auction);
        }
Ejemplo n.º 13
0
        //To get user bids with customer id
        public static AuctionResponse GetCustomerBids(int customerId)
        {
            auctionEntities = new AuctionSystemEntities();
            AuctionResponse auctionResponse = new AuctionResponse();
            var             auctions        = auctionEntities.auctions.Where(c => c.customer_id == customerId).OrderByDescending(d => d.auction_datetime).ToList();

            if (auctions == null)
            {
                auctionResponse.Error = new Error {
                    Code = ErrorCodes.NoAuctions, Message = "This customer does not contain any auctions"
                };
                return(auctionResponse);
            }

            //if auction is not null retrieve current highest bid price from Auction table with productid and max bid price
            auctionResponse.Auctions = new List <Model.Message.Auction>();

            foreach (auction auction in auctions)
            {
                var userAuction    = new Model.Message.Auction();
                var highestbidprce = auctionEntities.auctions.Where(c => c.product_id == auction.product_id).Max(p => p.bid_price);

                userAuction.AuctionId              = auction.id;
                userAuction.CustomerId             = auction.customer_id;
                userAuction.ProductId              = auction.product_id;
                userAuction.BidPrice               = auction.bid_price;
                userAuction.ProductBidTime         = auction.product.product_bid_time.ToString(format);
                userAuction.ProductName            = auction.product.product_Name;
                userAuction.ProductDescription     = auction.product.product_description;
                userAuction.CurrentHighestBidPrice = highestbidprce;
                userAuction.BidStatus              = auction.bid_status.status;
                userAuction.BidStatusReason        = auction.bid_status_reason.status_reason;
                auctionResponse.Auctions.Add(userAuction);
            }
            return(auctionResponse);
        }
Ejemplo n.º 14
0
        public static RegisterResponse RegisterCustomer(RegisterRequest register)
        {
            auctionEntities = new AuctionSystemEntities();
            RegisterResponse registerResponse = new RegisterResponse();
            //To retrieve customers based on customer email from customer table in database.
            customer existingCustomer = auctionEntities.customers.Where(c => c.customer_email == register.CustomerEmail).FirstOrDefault();

            //Check if customer exists or not
            if (existingCustomer != null)
            {
                //if customer alreay exist then set fault as customer already exist.
                registerResponse.Fault = new Error {
                    Code = ErrorCodes.EmailAlreadyExist, Message = "User Email already exist"
                };
                return(registerResponse);
            }

            //if customer does not exist create customer
            customer customer = new customer();

            customer.customer_firstname = register.CustomerFirstName;
            customer.customer_lastname  = register.CustomerLastName;
            customer.customer_email     = register.CustomerEmail;
            customer.customer_password  = HashPassword(register.CustomerPassword);
            customer.customer_phone     = register.CustomerPhone;

            //Add customer to customer table in database and save
            auctionEntities.customers.Add(customer);
            auctionEntities.SaveChanges();


            customer_address address = new customer_address();

            address.Address1      = register.Address1;
            address.Address2      = register.Address2;
            address.City          = register.City;
            address.Address_State = register.State;
            address.Zipcode       = register.Zipcode;
            address.country       = register.Country;
            address.customer_id   = customer.id;

            auctionEntities.customer_address.Add(address);
            auctionEntities.SaveChanges();

            customer_payment payment = new customer_payment();

            payment.card_number       = register.CardNumber;
            payment.card_pin          = register.CardPin;
            payment.card_holdername   = register.CardHolderName;
            payment.card_expirydate   = register.CardExpiryDate;
            payment.payment_method_id = register.PaymentMethodId;
            payment.customer_id       = customer.id;
            payment.address_id        = address.id;

            auctionEntities.customer_payment.Add(payment);
            auctionEntities.SaveChanges();

            registerResponse.CustomerId        = customer.id;
            registerResponse.CustomerEmail     = customer.customer_email;
            registerResponse.CustomerFirstName = customer.customer_firstname;
            registerResponse.CustomerLastName  = customer.customer_lastname;

            return(registerResponse);
        }
Ejemplo n.º 15
0
        //To post user bids
        public static AuctionResponse CreateBid(AuctionRequest auctionRequest)
        {
            AuctionResponse auctionResponse = new AuctionResponse();

            auctionEntities = new AuctionSystemEntities();
            Model.Message.Auction auction = new Model.Message.Auction();

            //Retrieve user products to check if user is bidding on own product
            var userproduct = auctionEntities.products.Where(c => c.id == auctionRequest.ProductId && c.customer_id == auctionRequest.CustomerId).FirstOrDefault();

            if (userproduct != null)
            {
                auctionResponse.Error = new Error {
                    Code = ErrorCodes.BidNotAllowed, Message = "Bidding on your product is not allowed"
                };
                return(auctionResponse);
            }

            //retrieve auctions from autions table with productid to see if this is the first bid on product
            var dbAuctions = auctionEntities.auctions.Where(c => c.product_id == auctionRequest.ProductId).ToList();

            if (dbAuctions == null || dbAuctions.Count == 0)
            {
                //Retrieve product from product table to compare the bidding price
                var dbProduct = auctionEntities.products.Where(c => c.id == auctionRequest.ProductId).FirstOrDefault();
                if (dbProduct == null)
                {
                    auctionResponse.Error = new Error {
                        Code = ErrorCodes.ProductUnavailable, Message = "Product is not available"
                    };
                    return(auctionResponse);
                }
                if (dbProduct.product_bid_price > auctionRequest.BidPrice)
                {
                    auctionResponse.Error = new Error {
                        Code = ErrorCodes.InvalidBidPrice, Message = "Bid price cannot be less than minimum bid price"
                    };
                    return(auctionResponse);
                }

                auction dbAuction = new auction()
                {
                    customer_id      = auctionRequest.CustomerId,
                    product_id       = auctionRequest.ProductId,
                    bid_price        = auctionRequest.BidPrice,
                    auction_datetime = auctionRequest.ProductBidTime,
                    bidstatus_id     = (int)BidStatusCode.Active,
                    reason_id        = (int)BidReasonCode.AuctionIsOpen
                };
                auctionEntities.auctions.Add(dbAuction);
                auctionEntities.SaveChanges();


                auction = new Model.Message.Auction()
                {
                    AuctionId = dbAuction.id,
                    ProductId = dbAuction.product_id
                };

                auctionResponse.Auctions = new List <Model.Message.Auction>();
                //add userauction object to list
                auctionResponse.Auctions.Add(auction);
                return(auctionResponse);
            }

            var currentHighestBid = dbAuctions.Max(p => p.bid_price);

            //check if user has product in auction table already
            var dbExistingAuction = auctionEntities.auctions.Where(c => c.product_id == auctionRequest.ProductId && c.customer_id == auctionRequest.CustomerId).FirstOrDefault();

            if (dbExistingAuction != null)
            {
                if (auctionRequest.BidPrice < currentHighestBid)
                {
                    auctionResponse.Error = new Error {
                        Code = ErrorCodes.InvalidBidPrice, Message = "Bid price cannot be less than current highest bid price"
                    };
                    return(auctionResponse);
                }
                auction = new Model.Message.Auction();
                dbExistingAuction.bid_price = auctionRequest.BidPrice;
                auctionEntities.SaveChanges();

                auction.AuctionId        = dbExistingAuction.id;
                auction.ProductId        = dbExistingAuction.product_id;
                auctionResponse.Auctions = new List <Model.Message.Auction>();
                auctionResponse.Auctions.Add(auction);
                return(auctionResponse);
            }

            //compare currenthighestbid with userbid
            if (currentHighestBid >= auctionRequest.BidPrice)
            {
                //if user bid is less then set fault as invalid price
                auctionResponse.Error = new Error {
                    Code = ErrorCodes.InvalidBidPrice, Message = "Bid price cannot be less than current highest bid"
                };
                return(auctionResponse);
            }

            //if user bid is higher than currenthighestbid
            auction Auctions = new auction()
            {
                customer_id      = auctionRequest.CustomerId,
                product_id       = auctionRequest.ProductId,
                bid_price        = auctionRequest.BidPrice,
                auction_datetime = auctionRequest.ProductBidTime,
                bidstatus_id     = (int)BidStatusCode.Active,
                reason_id        = (int)BidReasonCode.AuctionIsOpen
            };

            auctionEntities.auctions.Add(Auctions);
            auctionEntities.SaveChanges();

            auction = new Model.Message.Auction()
            {
                AuctionId = Auctions.id,
                ProductId = Auctions.product_id
            };
            auctionResponse.Auctions = new List <Model.Message.Auction>();
            auctionResponse.Auctions.Add(auction);
            return(auctionResponse);
        }