*any help here please ?*

On Saturday, June 13, 2015 at 2:13:46 AM UTC+2, Ahmed Amen wrote:
>
> Hi
>
> i have use angular to save invoice in SQl Database throw API Controller - 
> it works and invoice saved to database as i need - but i need to alert user 
> the OrderID of the invoice he saved it on database :
>
>         $scope.saveInvoice = function () {
>             $http.post("/api/customerService/SaveInvoice", $scope.invoice)
>
>             .success(function (data) {
>                 // Clear AutoComplete Text
>                 $("#Customers").data("kendoAutoComplete").value("");
>
>                 $scope.invoice = [];
>                 $scope.orders = [];
>
>                 $scope.tax = 0.00;
>                 $scope.PercentageDiscount = 0.00;
>                 $scope.MoneyDiscount = 0.00;
>
>                 alertify.set('notifier', 'position', 'top-left');
>                 alertify.success('تم حفظ الفاتورة', 3); // here i will 
> alert user the OrderID of Invoice he saved in database ??!!
>
>                 $("#Customers").val("عميل نقدى").trigger('change');
>
>                 var today = new Date().toLocaleDateString();
>                 $("#OrderDate").val(today).trigger('change');
>             })
>             .error(function (data) {
>                 // called asynchronously if an error occurs
>                 // or server returns response with an error status.
>                 alertify.set('notifier', 'position', 'top-right');
>                 alertify.error('يوجد خطأ', 2);
>                 return;
>             });
>         };
>
> *API Controller (i return the OrderID but i don't know how can i get in 
> angular code above ??!!)*
>
>
>
>
>
>
>
>
>
>
> *        public IHttpActionResult SaveInvoice(Order_VM newOrderMaster)    
>     {            if (newOrderMaster != null)            {                
> var order = new Order();                int? custom;                if 
> (newOrderMaster.CustomerID == null || newOrderMaster.CustomerID == 0)      
>           {                    custom = db.Customers.Where(i => 
> i.ContactName == newOrderMaster.ContactName).SingleOrDefault().CustomerID;  
>               }                else                {                    
> custom = newOrderMaster.CustomerID;                }                
> order.CustomerID = custom;                order.OrderDate = 
> newOrderMaster.OrderDate;                order.Freight = 
> (decimal)newOrderMaster.Total;                //order.type = "بيع";        
>         db.Orders.Add(order);                db.SaveChanges();              
>   newOrderMaster.OrderID = order.OrderID;            }            // loop 
> throw items list to check Stock & add to database with invoice no          
>   foreach (var item in listOfOrder_Final)            {                
> item.OrderID = newOrderMaster.OrderID;                var model = 
> db.Products.Find(item.ProductID);                if (model.stock >= 
> item.Quantity)                {                    model.stock = 
> model.stock - item.Quantity;                    db.Entry(model).State = 
> EntityState.Modified;                    statusCode = 200;                
> }                if (statusCode == 200)                {                    
> // save to DB                    var orderdetails = new Order_Detail();    
>                 orderdetails.OrderID = item.OrderID;                    
> orderdetails.ProductID = item.ProductID;                    
> orderdetails.UnitPrice = (decimal)item.sell_price;                    
> orderdetails.Quantity = item.Quantity;                    
> orderdetails.Quantity_buy = item.Quantity;                    
> orderdetails.Total = item.Total_Item;                    
> db.Order_Details.Add(orderdetails);                    db.SaveChanges();    
>             }            }            listOfOrders.Clear();            
> listOfOrder_Final.Clear();            return Ok(newOrderMaster.OrderID);    
>     }so please how can i do it and get OrderID the i return from API 
> Controller to alert it to user ?*
>
> *Thanks a lot ...*
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to