public ActionResult <IDataPacker> DeleteSalesOrderByKey(IDataUnpacker unpacker)
        {
            var packer      = new DataPacker();
            var modelName   = unpacker.GetValue <string>("arm1");
            var saleOrderId = unpacker.GetValue <int>("arm2");
            var status      = "Success";

            try
            {
                switch (modelName)
                {
                case "SaleOrder":
                    status = _saleService.DeleteSalesOrder(saleOrderId);
                    break;

                case "OrderDetail":
                    var saleDetailId = unpacker.GetValue <int>("arm3");
                    status = _saleService.Delete <SalesOrderDetail>(true,
                                                                    m => m.SalesOrderDetailID == saleDetailId, saleOrderId);
                    break;
                }
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }

            packer.AddValue("Status", status);

            return(packer);
        }
Exemple #2
0
        public ActionResult <IDataPacker> SaveHistoryPrices(IDataUnpacker unpacker)
        {
            var packer = new DataPacker();

            var subcate = unpacker.GetModelStore <SubCategory>("dw1",
                                                               ChangeTrackingStrategy.PropertyState);
            var product = unpacker.GetModelStore <Product>("dw2",
                                                           ChangeTrackingStrategy.PropertyState);
            var prices = unpacker.GetModelStore <HistoryPrice>("dw3",
                                                               ChangeTrackingStrategy.PropertyState);

            try
            {
                _productService.SaveHistoryPrices(subcate, product, prices);

                packer.AddModelStore("SubCategory", subcate);
                packer.AddModelStore("Product", product);
                packer.AddModelStore("Product.HistoryPrice", prices);
                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);
        }
Exemple #4
0
        public ActionResult <IDataPacker> SaveProductTwotier(IDataUnpacker unpacker)
        {
            var packer = new DataPacker();

            var product = unpacker.GetModelStore <Product>("dw1",
                                                           ChangeTrackingStrategy.PropertyState);
            var prices = unpacker.GetModelStore <HistoryPrice>("dw2",
                                                               ChangeTrackingStrategy.PropertyState);

            try
            {
                var productId = _productService.SaveProductAndPrice(product, prices);

                packer.AddModelStore("Product",
                                     _productService.Retrieve <Product>(productId));
                packer.AddModelStore("Product.HistoryPrice",
                                     _productService.Retrieve <HistoryPrice>(productId));

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

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

            var orderHeader = unpacker.GetModelStore <SalesOrderHeader>("dw1",
                                                                        ChangeTrackingStrategy.PropertyState);

            var orderDetail = unpacker.GetModelStore <SalesOrderDetail>("dw2",
                                                                        ChangeTrackingStrategy.PropertyState);

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

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

            return(packer);
        }
Exemple #6
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);
        }
Exemple #7
0
        public ActionResult <IDataPacker> DeleteSalesOrderByKey(IDataUnpacker unpacker)
        {
            var packer      = new DataPacker();
            var modelName   = unpacker.GetValue <string>("arm1");
            var saleOrderId = unpacker.GetValue <int>("arm2");
            var status      = "Success";

            try
            {
                switch (modelName)
                {
                case "SaleOrder":
                    status = _saleService.DeleteSalesOrder(saleOrderId);
                    break;

                case "OrderDetail":
                    var saleDetailId = unpacker.GetValue <int>("arm3");
                    status = _saleService.Delete("d_order_detail_list", true,
                                                 "SalesOrderDetailID = " + saleDetailId.ToString(), saleOrderId);
                    break;
                }
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            packer.AddValue("Status", status);

            return(packer);
        }
Exemple #8
0
        public ActionResult <IDataPacker> Retrieve(string dwname, int id)
        {
            var packer = new DataPacker();

            try
            {
                switch (dwname)
                {
                case "d_subcategory":
                    packer.AddModelStore("SubCategory",
                                         _productService.Retrieve <SubCategoryList>(id));

                    break;

                case "d_product":
                    packer.AddModelStore("Product",
                                         _productService.Retrieve <ProductList>(id));
                    packer.AddModelStore("dddwSubCategory",
                                         _productService.Retrieve <SubCategoryList>(id));

                    break;

                case "d_history_price":
                    packer.AddModelStore("HistoryPrice", _productService.Retrieve <HistoryPrice>(id));
                    packer.AddModelStore("dddwProduct", _productService.Retrieve <DdProduct>(id));
                    var photo = _productService.Retrieve <ViewProductPhoto>(id);
                    if (photo.Count > 0)
                    {
                        packer.AddValue("photo", photo[0].LargePhoto);
                        packer.AddValue("photoname", photo[0].LargePhotoFileName);
                    }
                    else
                    {
                        packer.AddValue("photo", "");
                        packer.AddValue("photoname", "");
                    }

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

            return(packer);
        }
        public ActionResult <IDataPacker> Retrieve(string dwname, int id)
        {
            var packer = new DataPacker();

            try
            {
                switch (dwname)
                {
                case "d_subcategory":
                    packer.AddDataStore("SubCategory",
                                        _productService.Retrieve("d_subcategory_list", id), true);

                    break;

                case "d_product":
                    packer.AddDataStore("Product",
                                        _productService.Retrieve("d_product", id));

                    packer.AddDataStore("dddwSubCategory",
                                        _productService.Retrieve("d_subcategory_list", id));

                    break;

                case "d_history_price":
                    packer.AddDataStore("HistoryPrice",
                                        _productService.Retrieve("d_history_price", id));
                    packer.AddDataStore("dddwProduct",
                                        _productService.Retrieve("d_dddw_product"));

                    if (_productService.retrieveProductPhote(id, out string photoname,
                                                             out byte[] largePhoto))
                    {
                        packer.AddValue("photo", largePhoto);
                        packer.AddValue("photoname", photoname);
                    }
                    else
                    {
                        packer.AddValue("photo", "");
                        packer.AddValue("photoname", "");
                    }

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

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

            try
            {
                var personAddress = unpacker.GetModelStore <BusinessEntityAddress>("dw1",
                                                                                   ChangeTrackingStrategy.PropertyState);
                var personPhone = unpacker.GetModelStore <PersonPhone>("dw2",
                                                                       ChangeTrackingStrategy.PropertyState);
                var customer = unpacker.GetModelStore <Customer>("dw3",
                                                                 ChangeTrackingStrategy.PropertyState);

                if (personAddress.Count() > 0)
                {
                    status      = _personService.Update(true, personAddress);
                    intPersonId = personAddress.FirstOrDefault().Businessentityid;
                }

                if (personPhone.Count() > 0 && status == "Success")
                {
                    status      = _personService.Update(true, personPhone);
                    intPersonId = personPhone.FirstOrDefault().Businessentityid;
                }

                if (customer.Count() > 0 && status == "Success")
                {
                    status      = _personService.Update(true, customer);
                    intPersonId = customer.FirstOrDefault().Personid;
                }

                if (status == "Success")
                {
                    packer.AddModelStore("Person",
                                         _personService.Retrieve <Person>(intPersonId));
                    packer.AddModelStore("Person.PersonAddress",
                                         _personService.Retrieve <BusinessEntityAddress>(intPersonId));
                    packer.AddModelStore("Person.PersonPhone",
                                         _personService.Retrieve <PersonPhone>(intPersonId));
                    packer.AddModelStore("Person.Customer",
                                         _personService.Retrieve <Customer>(intPersonId));
                }

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

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

            var dwname   = unpacker.GetValue <string>("arm1");
            var personId = unpacker.GetValue <int>("arm2");
            var status   = "Success";

            try
            {
                switch (dwname)
                {
                case "Person":
                    status = _personService.DeletePerson(personId);

                    break;

                case "PersonAddress":
                    var addressId     = unpacker.GetValue <int>("arm3");
                    var addressTypeId = unpacker.GetValue <int>("arm4");
                    status = _personService.Delete("d_businessentityaddress", true,
                                                   "Addressid = " + addressId.ToString() + " And " +
                                                   "Addresstypeid = " + addressTypeId.ToString(),
                                                   personId);

                    break;

                case "PersonPhone":
                    var personNumber      = unpacker.GetValue <string>("arm3");
                    var phonenumbertypeid = unpacker.GetValue <int>("arm4");
                    status = _personService.Delete("d_personphone", true,
                                                   "Phonenumber = '" + personNumber.ToString() + "' And " +
                                                   "Phonenumbertypeid = " + phonenumbertypeid.ToString(),
                                                   personId);

                    break;

                case "Customer":
                    var customerId = unpacker.GetValue <int>("arm3");

                    status = _personService.Delete("d_customer", true, customerId);

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

            packer.AddValue("Status", status);

            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> DeleteByKey(IDataUnpacker unpacker)
        {
            var packer = new DataPacker();

            var dwname   = unpacker.GetValue <string>("arm1");
            var personId = unpacker.GetValue <int>("arm2");
            var status   = "Success";

            try
            {
                switch (dwname)
                {
                case "Person":
                    status = _personService.DeletePerson(personId);

                    break;

                case "PersonAddress":
                    var addressId     = unpacker.GetValue <int>("arm3");
                    var addressTypeId = unpacker.GetValue <int>("arm4");
                    status = _personService.Delete <BusinessEntityAddress>(true,
                                                                           m => m.Addressid == addressId &&
                                                                           m.Addresstypeid == addressTypeId, personId);

                    break;

                case "PersonPhone":
                    var personNumber      = unpacker.GetValue <string>("arm3");
                    var phonenumbertypeid = unpacker.GetValue <int>("arm4");
                    status = _personService.Delete <PersonPhone>(true,
                                                                 m => m.Phonenumber == personNumber &&
                                                                 m.Phonenumbertypeid == phonenumbertypeid, personId);
                    break;

                case "Customer":
                    var customerId = unpacker.GetValue <int>("arm3");

                    status = _personService.Delete <Customer>(true, customerId);

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

            packer.AddValue("Status", status);

            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);
        }
Exemple #15
0
        public ActionResult <IDataPacker> SaveChanges(IDataUnpacker unpacker)
        {
            var 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);
        }
Exemple #16
0
        public ActionResult <IDataPacker> DeleteAddressByKey(IDataUnpacker unpacker)
        {
            var packer    = new DataPacker();
            var addressId = unpacker.GetValue <int>("arm1");

            try
            {
                var status = _addressService.Delete <Address>(addressId);
                packer.AddValue("Status", status);
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
Exemple #17
0
        public ActionResult <IDataPacker> DeleteSubcategoryByKey(IDataUnpacker unpacker)
        {
            var packer    = new DataPacker();
            var subCateId = unpacker.GetValue <int>("arm1");

            try
            {
                var status = _productService.Delete <SubCategory>(subCateId);
                packer.AddValue("Status", status);
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
Exemple #18
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);
        }
Exemple #19
0
        public ActionResult <IDataPacker> DeleteProductByKey(IDataUnpacker unpacker)
        {
            var packer = new DataPacker();

            var productId = unpacker.GetValue <int>("arm1");

            try
            {
                var status = _productService.DeleteProduct(productId);

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

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

            var productCate = _productService.Retrieve("d_dddw_category");

            if (productCate.RowCount > 0)
            {
                intCateId = productCate.GetItem <int>(0, "productcategoryid");
            }

            packer.AddValue("CateId", intCateId.ToString());
            packer.AddDataStore("Category", productCate);
            packer.AddDataStore("SubCategory",
                                _productService.Retrieve("d_subcategory_list", intCateId), true);
            packer.AddDataStore("Units", _productService.Retrieve("d_dddw_unit"));

            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);
        }
Exemple #22
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);
        }
Exemple #23
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> 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;
        }
        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);
        }
Exemple #26
0
        public ActionResult <IDataPacker> SaveProductPhoto(IDataUnpacker unpacker)
        {
            var packer = new DataPacker();

            var productId    = unpacker.GetValue <int>("arm1");
            var photoName    = unpacker.GetValue <string>("arm2");
            var productPhoto = unpacker.GetValue <string>("arm3");

            byte[] bProductPhoto = Convert.FromBase64String(productPhoto);

            try
            {
                _productService.SaveProductPhoto(productId, photoName, bProductPhoto);
                packer.AddValue("Status", "Success");
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }

            return(packer);
        }
Exemple #27
0
        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.GetModelStore <SubCategory>("dw1",
                                                                         ChangeTrackingStrategy.PropertyState)
                                    .FirstOrDefault().Productsubcategoryid;
                    status = _productService.Delete <SubCategory>(subCateId);

                    break;

                case "Product":
                    var productId = unpacker.GetModelStore <ProductList>("deletedw1",
                                                                         ChangeTrackingStrategy.PropertyState)
                                    .FirstOrDefault().Productid;
                    status = _productService.DeleteProduct(productId);

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

            packer.AddValue("Status", status);

            return(packer);
        }