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); }
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> 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> 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> 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); }
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); }
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); }
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); }