Ejemplo n.º 1
0
        public async Task <IActionResult> PutSalesOrderLine(int id, SalesOrderLine salesOrderLine)
        {
            if (id != salesOrderLine.SalesOrderLineId)
            {
                return(BadRequest());
            }

            _context.Entry(salesOrderLine).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SalesOrderLineExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutUoM(int id, UoM uoM)
        {
            if (id != uoM.UoMId)
            {
                return(BadRequest());
            }

            _context.Entry(uoM).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UoMExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutCustomer(int id, Customer customer)
        {
            if (id != customer.CustomerId)
            {
                return(BadRequest());
            }

            _context.Entry(customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
        public bool UpdateQuotation(SalesOrder salesorder, IList <SalesOrderItems> salesorderitem, ref string ErrorMessage)
        {
            ErrorMessage = string.Empty;
            try
            {
                ordercontext.Entry(salesorder).State = EntityState.Modified;
                ordercontext.SaveChanges();

                foreach (var model in salesorderitem)
                {
                    if (model.IsDummy == 1)
                    {
                        ordercontext.Entry(model).State = EntityState.Deleted;
                        ordercontext.SaveChanges();
                    }
                    else
                    {
                        if (model.Sales_Order_Id == 0)
                        {
                            model.Sales_Order_Id = salesorder.Sales_Order_Id;
                            ordercontext.salesorderitem.Add(model);
                            ordercontext.SaveChanges();
                        }
                        else
                        {
                            ordercontext.Entry(model).State = EntityState.Modified;
                            ordercontext.SaveChanges();
                        }
                    }
                }

                return(true);
            }
            catch (DbEntityValidationException dbEx)
            {
                var errorList = new List <string>();

                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        errorList.Add(String.Format("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage));
                    }
                }
                return(false);
            }
        }
Ejemplo n.º 5
0
        public bool UpdateQuotationorder(SalesQuotation Quotation, IList <SalesQuotationItems> QuotationItemList, ref string ErrorMessage)
        {
            ErrorMessage = string.Empty;
            try
            {
                ordercontext.Entry(Quotation).State = EntityState.Modified;
                ordercontext.SaveChanges();

                foreach (var model1 in QuotationItemList)
                {
                    if (model1.IsDummy == 1)
                    {
                        ordercontext.Entry(model1).State = EntityState.Deleted;
                        ordercontext.SaveChanges();
                    }
                    else
                    {
                        if (model1.Sales_QtnItems_Id == 0)
                        {
                            model1.Sales_Qtn_Id = Quotation.Sales_Qtn_Id;
                            ordercontext.salesquotationitem.Add(model1);
                            ordercontext.SaveChanges();
                        }
                        else
                        {
                            ordercontext1.salesquotationitem.Attach(model1);
                            ordercontext1.Entry(model1).State = EntityState.Modified;
                            //goodscontext.SaveChanges();
                        }
                        ordercontext1.SaveChanges();
                    }
                }

                return(true);
            }
            //catch (Exception ex)
            //{
            //    ExceptionHandler.LogException(ex);
            //    ErrorMessage = ex.Message;
            //    return false;
            //}
            catch (DbEntityValidationException dbEx)
            {
                var errorList = new List <string>();

                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        errorList.Add(String.Format("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage));
                    }
                }
                return(false);
            }
        }
Ejemplo n.º 6
0
        public int UpdateSalesOrder(SalesOrder salesorderEntity)
        {
            int result = -1;

            if (salesorderEntity != null)
            {
                _context.Entry(salesorderEntity).State = EntityState.Modified;
                _context.SaveChanges();
                result = salesorderEntity.SalesOrderId;
            }
            return(result);
        }