예제 #1
0
        public ActionResult <IDataPacker> SaveChanges(IDataUnpacker unpacker)
        {
            var packer    = new DataPacker();
            var modelname = unpacker.GetValue <string>("arm1");
            var status    = "Success";

            try
            {
                switch (modelname)
                {
                case "SubCategory":
                    var subcate = unpacker.GetModelStore <SubCategoryList>("dw1",
                                                                           ChangeTrackingStrategy.PropertyState);
                    status = _productService.Update(true, subcate);

                    var modelId = subcate.FirstOrDefault().Productcategoryid;

                    packer.AddModelStore("SubCategory", subcate);

                    break;

                case "Product":
                    var prod = unpacker.GetModelStore <Product>("dw1",
                                                                ChangeTrackingStrategy.PropertyState);
                    status = _productService.Update(true, prod);

                    var productId = prod.FirstOrDefault().Productid;
                    packer.AddModelStore("Product",
                                         _productService.Retrieve <Product>(productId));
                    packer.AddModelStore("Product.HistoryPrice",
                                         _productService.Retrieve <HistoryPrice>(productId));

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

            packer.AddValue("Status", status);

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

            try
            {
                var person = unpacker.GetModelStore <Person>("dw1",
                                                             ChangeTrackingStrategy.PropertyState);

                var personAddress = unpacker.GetModelStore <BusinessEntityAddress>("dw2",
                                                                                   ChangeTrackingStrategy.PropertyState);

                var personPhone = unpacker.GetModelStore <PersonPhone>("dw3",
                                                                       ChangeTrackingStrategy.PropertyState);

                var customer = unpacker.GetModelStore <Customer>("dw4",
                                                                 ChangeTrackingStrategy.PropertyState);

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

                if (personId > 0)
                {
                    packer.AddModelStore("Person",
                                         _personService.Retrieve <Person>(personId));
                    packer.AddModelStore("Person.PersonAddress",
                                         _personService.Retrieve <BusinessEntityAddress>(personId));
                    packer.AddModelStore("Person.PersonPhone",
                                         _personService.Retrieve <PersonPhone>(personId));
                    packer.AddModelStore("Person.Customer",
                                         _personService.Retrieve <Customer>(personId));
                }
                packer.AddValue("Status", "Success");
            }

            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
            return(packer);
        }
예제 #3
0
        public ActionResult <IDataPacker> WinOpen()
        {
            var packer = new DataPacker();

            var productCate = _productService.Retrieve <Category>();

            if (productCate.Count == 0)
            {
                return(NotFound());
            }

            var cateId = productCate.FirstOrDefault().Productcategoryid;

            packer.AddValue("CateId", cateId.ToString());
            packer.AddModelStore("Category", productCate);
            packer.AddModelStore("SubCategory",
                                 _productService.Retrieve <SubCategoryList>(cateId));
            packer.AddModelStore("Units", _productService.Retrieve <DdUnit>());

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

            try
            {
                packer.AddModelStore("Address",
                                     _personService.Retrieve <DdAddress>());
                packer.AddModelStore("AddressType",
                                     _personService.Retrieve <DdAddressType>());
                packer.AddModelStore("PhonenumberType",
                                     _personService.Retrieve <DdPhoneNumberType>());
                packer.AddModelStore("CustomerTerritory",
                                     _personService.Retrieve <DdTerritory>());
                packer.AddModelStore("Store",
                                     _personService.Retrieve <DdStore>());
                packer.AddModelStore("Person",
                                     _personService.Retrieve <PersonList>("IN"));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult <IDataPacker> RetrievePersonByKey(int personId)
        {
            var packer = new DataPacker();

            try
            {
                packer.AddModelStore("Person",
                                     _personService.Retrieve <Person>(personId));
                packer.AddModelStore("Person.PersonAddress",
                                     _personService.Retrieve <BusinessEntityAddress>(personId));
                packer.AddModelStore("Person.PersonPhone",
                                     _personService.Retrieve <PersonPhone>(personId));
                packer.AddModelStore("Person.Customer",
                                     _personService.Retrieve <Customer>(personId));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult <IDataPacker> RetrieveSaleOrderDetail(
            int salesOrderId, int customerId)
        {
            var packer = new DataPacker();

            try
            {
                packer.AddModelStore("SalesOrderDetail",
                                     _saleService.Retrieve <SalesOrderDetail>(salesOrderId));

                packer.AddModelStore("DddwAddress",
                                     _saleService.Retrieve <DdCustomerAddress>(customerId));

                packer.AddModelStore("DddwCreditcard",
                                     _saleService.Retrieve <DdCreditcard>(customerId));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
        public ActionResult <IDataPacker> RetrieveDropdownModel(string modelName, int CodeId)
        {
            var packer = new DataPacker();

            try
            {
                switch (modelName)
                {
                case "Customer":
                    packer.AddModelStore("DddwAddress",
                                         _saleService.Retrieve <DdCustomerAddress>(CodeId));
                    packer.AddModelStore("DddwCreditcard",
                                         _saleService.Retrieve <DdCreditcard>(CodeId));
                    break;
                }
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

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

            try
            {
                packer.AddModelStore("Customer",
                                     _saleService.Retrieve <DdCustomer>());
                packer.AddModelStore("SalesPerson",
                                     _saleService.Retrieve <DdSalesPerson>());
                packer.AddModelStore("SalesTerritory",
                                     _saleService.Retrieve <DdSalesTerritory>());
                packer.AddModelStore("ShipMethod",
                                     _saleService.Retrieve <DdShipMethod>());
                packer.AddModelStore("OrderProduct",
                                     _saleService.Retrieve <DdOrderProduct>());
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
예제 #9
0
        public ActionResult <IDataPacker> WinOpen()
        {
            var packer = new DataPacker();

            var stateProvince = _addressService.Retrieve <DdStateProvince>();

            if (stateProvince.Count == 0)
            {
                return(NotFound());
            }

            packer.AddModelStore("StateProvince", stateProvince);

            return(packer);
        }
        public ActionResult <IDataPacker> RetrieveSaleOrderList(
            int customerId, string dateFrom, string dateTo)
        {
            var packer   = new DataPacker();
            var fromDate = DateTime.Parse(dateFrom);
            var toDate   = DateTime.Parse(dateTo);

            try
            {
                packer.AddModelStore("SalesOrderHeader",
                                     _saleService.Retrieve <SalesOrderHeaderList>(customerId,
                                                                                  fromDate, toDate));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status404NotFound, e.Message));
            }

            return(packer);
        }
예제 #11
0
        public ActionResult <IDataPacker> RetrieveAddress(int provinceId, string city)
        {
            var packer = new DataPacker();

            if (city == "$")
            {
                city = "%";
            }

            var addressData = _addressService.Retrieve <AddressList>(provinceId, city);

            if (addressData.Count == 0)
            {
                return(NotFound());
            }

            packer.AddModelStore("Address", addressData);

            return(packer);
        }
예제 #12
0
        public ActionResult <IDataPacker> SaveChanges(IDataUnpacker unpacker)
        {
            var packer = new DataPacker();

            var addressModel = unpacker.GetModelStore <Address>("dw1",
                                                                ChangeTrackingStrategy.PropertyState, MappingMethod.Key);

            try
            {
                var status = _addressService.Update(addressModel);
                packer.AddValue("Status", status);
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            packer.AddModelStore("Address", addressModel);

            return(packer);
        }
        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.GetModelStore <SalesOrderHeader>
                                          ("dw1", ChangeTrackingStrategy.PropertyState);
                    status = _saleService.Update(true, orderHeader);
                    packer.AddModelStore("SalesOrderHeader", orderHeader);

                    break;

                case "SaleOrderDetail":
                    var orderDetail = unpacker.GetModelStore <SalesOrderDetail>
                                          ("dw1", ChangeTrackingStrategy.PropertyState);
                    status = _saleService.Update(true, orderDetail);

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

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

            packer.AddValue("Status", status);

            return(packer);
        }