Exemple #1
0
        public ActionResult <IDataPacker> SaveSalesOrderAndDetail(IDataUnpacker unPacker)
        {
            var packer      = new DataPacker();
            var orderHeader = unPacker.GetDataStore("dw1", "d_order_header_free");
            var orderDetail = unPacker.GetDataStore("dw2", "d_order_detail_list");

            try
            {
                var saleOrderId = _saleService.SaveSalesOrderAndDetail(orderHeader,
                                                                       orderDetail);

                if (saleOrderId > 0)
                {
                    packer.AddDataStore("SalesOrderHeader",
                                        _saleService.Retrieve("d_order_header_free", saleOrderId));
                    packer.AddDataStore("SalesOrderHeader.SalesOrderDetail",
                                        _saleService.Retrieve("d_order_detail_list", saleOrderId));
                }
                packer.AddValue("Status", "Success");
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult <IDataPacker> SavePerson(IDataUnpacker unpacker)
        {
            var packer = new DataPacker();

            try
            {
                var person        = unpacker.GetDataStore("dw1", "d_person");
                var personAddress = unpacker.GetDataStore("dw2", "d_address");
                var personPhone   = unpacker.GetDataStore("dw3", "d_personphone");
                var customer      = unpacker.GetDataStore("dw4", "d_customer");

                var personId = _personService.SavePerson(person, personAddress,
                                                         personPhone, customer);

                if (personId > 0)
                {
                    packer.AddDataStore("Person",
                                        _personService.Retrieve("d_person", personId));
                    packer.AddDataStore("Person.PersonAddress",
                                        _personService.Retrieve("d_businessentityaddress", personId));
                    packer.AddDataStore("Person.PersonPhone",
                                        _personService.Retrieve("d_personphone", personId));
                    packer.AddDataStore("Person.Customer",
                                        _personService.Retrieve("d_customer", personId));
                }
                packer.AddValue("Status", "Success");
            }

            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult <IDataPacker> Savechanges(IDataUnpacker unpacker)
        {
            var packer = new DataPacker();

            var status      = "Success";
            int?intPersonId = 0;

            try
            {
                var personAddress = unpacker.GetDataStore("dw1", "d_businessentityaddress");
                var personPhone   = unpacker.GetDataStore("dw2", "d_personphone");
                var customer      = unpacker.GetDataStore("dw3", "d_customer");

                if (personAddress.RowCount > 0)
                {
                    status      = _personService.Update(true, personAddress);
                    intPersonId = personAddress.GetItem <int?>(0, "businessentityid");
                }

                if (personPhone.RowCount > 0 && status == "Success")
                {
                    status      = _personService.Update(true, personPhone);
                    intPersonId = personPhone.GetItem <int?>(0, "businessentityid");
                }

                if (customer.RowCount > 0 && status == "Success")
                {
                    status      = _personService.Update(true, customer);
                    intPersonId = customer.GetItem <int?>(0, "personid");
                }

                if (status == "Success")
                {
                    packer.AddDataStore("Person",
                                        _personService.Retrieve("d_person", intPersonId));
                    packer.AddDataStore("Person.PersonAddress",
                                        _personService.Retrieve("d_businessentityaddress", intPersonId));
                    packer.AddDataStore("Person.PersonPhone",
                                        _personService.Retrieve("d_personphone", intPersonId));
                    packer.AddDataStore("Person.Customer",
                                        _personService.Retrieve("d_customer", intPersonId));
                }

                packer.AddValue("Status", status);
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult<IDataPacker> Delete(IDataUnpacker unpacker)
        {
            var packer = new DataPacker();

            var status = "Success";
            var modelname = unpacker.GetValue<string>("arm1");

            try
            {
                switch (modelname)
                {
                    case "SubCategory":
                        var subCateId = unpacker.GetDataStore("dw1", "d_subcategory")
                                                .FirstOrDefault<D_Subcategory>()
                                                .Productsubcategoryid;

                        status = _productService.Delete("d_subcategory", subCateId);

                        break;

                    case "Product":
                        var productId = unpacker.GetDataStore("deletedw1", "d_product")
                                                .FirstOrDefault<D_Product>()
                                                .Productid;

                        status = _productService.DeleteProduct(productId);

                        break;
                }
            }
            catch (Exception e)
            {
                return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
            }

            packer.AddValue("Status", status);

            return packer;
        }
Exemple #5
0
        public ActionResult <IDataPacker> SaveChanges(IDataUnpacker unpacker)
        {
            string status    = "Success";
            var    packer    = new DataPacker();
            var    modelname = unpacker.GetValue <string>("arm1");

            try
            {
                switch (modelname)
                {
                case "SaleOrderHeader":
                    var orderHeader = unpacker.GetDataStore("dw1", "d_order_header_free");
                    status = _saleService.Update(true, orderHeader);

                    packer.AddDataStore("SalesOrderHeader", orderHeader);

                    break;

                case "SaleOrderDetail":
                    var orderDetail = unpacker.GetDataStore("dw1", "d_order_detail_list");
                    status = _saleService.Update(true, orderDetail);

                    packer.AddValue("SaleOrderDetail.SalesOrderDetail",
                                    orderDetail.RowCount);

                    break;
                }
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            packer.AddValue("Status", status);

            return(packer);
        }
        public ActionResult <IDataPacker> SaveChanges(IDataUnpacker unpacker)
        {
            string status = String.Empty;

            var packer = new DataPacker();

            var detail = unpacker.GetDataStore("dw1");

            try
            {
                status = _addressService.Update(detail);
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            packer.AddDataStore("Address", detail);
            packer.AddValue("Status", status);

            return(packer);
        }