public ActionResult AddCustomer(OrderDetails model)
        {
            if (ModelState.IsValid)
            {
                if (repository.AddCustomer(model))
                {
                    ViewBag.Success = "Records inserted successfully";

                   return RedirectToAction("GetTransactionDetails", "OrderDetails");
                }
                else
                {
                    ViewBag.Success = "Something went wrong. Please try later";
                }

            }
            return View();
        }
        /// <summary>
        /// add the 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddCustomer(OrderDetails model)
        {
            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(connectionString))
                {
                    using (SqlCommand sqlcmd = new SqlCommand("AddNewCustomer", sqlConnection))
                    {
                        sqlConnection.Open();
                        sqlcmd.CommandType = CommandType.StoredProcedure;
                        sqlcmd.Parameters.Add("@customerName", SqlDbType.NVarChar).Value = model.CustomerName;
                        sqlcmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = model.Email;
                        sqlcmd.Parameters.Add("@BillingAddress", SqlDbType.NVarChar).Value = model.BillingAddress;
                        sqlcmd.Parameters.Add("@ShippingAddress", SqlDbType.NVarChar).Value = model.ShippingAddress;
                        sqlcmd.Parameters.Add("@Number", SqlDbType.NVarChar).Value = model.Number;
                        sqlcmd.Parameters.Add("@NetAmount", SqlDbType.Decimal).Value = model.NetAmount;
                        sqlcmd.Parameters.Add("@Quantity", SqlDbType.Int).Value = model.Quantity;
                        sqlcmd.Parameters.Add("@OrderAmount", SqlDbType.Decimal).Value = model.OrderAmount;
                        sqlcmd.Parameters.Add("@Tax", SqlDbType.Decimal).Value = model.Tax;
                        sqlcmd.Parameters.Add("@Discount", SqlDbType.Decimal).Value = model.Discount;
                        sqlcmd.Parameters.Add("@Rate", SqlDbType.Decimal).Value = model.Rate;
                        sqlcmd.Parameters.Add("@amount", SqlDbType.Decimal).Value = model.Amount;
                        sqlcmd.Parameters.Add("@CustomerID", SqlDbType.Int).Value = model.CustomerID;
                        sqlcmd.Parameters.Add("@Orderno", SqlDbType.Int).Value = model.OrderID;
                        sqlcmd.Parameters.Add("@OrderItemNumber", SqlDbType.Int).Value = model.OrderItemID;
                        sqlcmd.Parameters.Add("@ProductID", SqlDbType.Int).Value = 4;
                        int Success = sqlcmd.ExecuteNonQuery();
                        sqlConnection.Close();
                        if (Success > 0)
                        {
                            return true;
                        }
                        return false;
                    }
                }

            }
            catch (Exception ex)
            {
                ExceptionHandling.SaveException(ex);
                return false;
            }
        }
        /// <summary>
        /// add the 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddCustomer(OrderDetails model)
        {
            try
            {
                var objCustomerDetails = new ClientDetail();

                objCustomerDetails.Name = model.CustomerName;
                objCustomerDetails.Email = model.Email;
                objCustomerDetails.BillingAddress = model.BillingAddress;
                objCustomerDetails.ShippingAddress = model.ShippingAddress;
                objCustomerDetails.Number = model.Number;
                ObjEntity.ClientDetails.Add(objCustomerDetails);
                ObjEntity.SaveChanges();

                var objContractDetail = new ContractDetail();
                objContractDetail.NetAmount = model.NetAmount;
                objContractDetail.Quantity = model.Quantity;
                objContractDetail.OrderAmount = model.OrderAmount;
                objContractDetail.Tax = model.Tax;
                objContractDetail.Discount = model.Discount;
                objContractDetail.IsActive = true;
                objContractDetail.TransactionDate = DateTime.Now;
                objContractDetail.Customer_ID = objCustomerDetails.ID; ;
                ObjEntity.ContractDetails.Add(objContractDetail);
               int OrderNo= ObjEntity.SaveChanges();
                var OrderItemDetails = new OrderItemDetail();
                OrderItemDetails.Rate = model.Rate;
                OrderItemDetails.Order_ID = objContractDetail.ID;
                OrderItemDetails.Product_ID = 4;
                OrderItemDetails.Quantity = model.Quantity.Value;

                OrderItemDetails.Amount = model.Amount;
                ObjEntity.OrderItemDetails.Add(OrderItemDetails);
                ObjEntity.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                ExceptionHandling.SaveException(ex);
                return false;
            }
        }
        /// <summary>
        /// update the order data
        /// </summary>
        /// <param name="model"></param>
        /// <param name="productName"></param>
        /// <returns></returns>
        public bool UpdateDetails(OrderDetails model, int productID)
        {
            try
            {
                var objCustomerDetails = ObjEntity.ClientDetails.Where(x => x.ID == model.CustomerID).FirstOrDefault();

                objCustomerDetails.Name = model.CustomerName;
                objCustomerDetails.Email = model.Email;
                objCustomerDetails.BillingAddress = model.BillingAddress;
                objCustomerDetails.ShippingAddress = model.ShippingAddress;
                objCustomerDetails.Number = model.Number;

                var objContractDetail = ObjEntity.ContractDetails.Where(x => x.ID == model.OrderID).FirstOrDefault();

                objContractDetail.NetAmount = model.NetAmount;
                objContractDetail.Quantity = model.Quantity;
                objContractDetail.OrderAmount = model.OrderAmount;
                objContractDetail.Tax = model.Tax;
                objContractDetail.Discount = model.Discount;

                var OrderItemDetails = ObjEntity.OrderItemDetails.Where(x => x.ID == model.OrderID).FirstOrDefault();
                OrderItemDetails.Rate = model.Rate;
                OrderItemDetails.Quantity = model.Quantity.Value;
                OrderItemDetails.Amount = model.Amount;

                ObjEntity.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                ExceptionHandling.SaveException(ex);
                return false;
            }
        }