当前位置: 首页>>代码示例>>C#>>正文


C# ProductRepository.Save方法代码示例

本文整理汇总了C#中ProductRepository.Save方法的典型用法代码示例。如果您正苦于以下问题:C# ProductRepository.Save方法的具体用法?C# ProductRepository.Save怎么用?C# ProductRepository.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProductRepository的用法示例。


在下文中一共展示了ProductRepository.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update_Product0_name_to_nill

        public void Update_Product0_name_to_nill()
        {

            
            AutoMapper.Mapper.CreateMap<DataAvail.UralAppModel.Product, Product>()
                .ForMember(p => p.id, opt => opt.MapFrom(p => p.Id))
                .ForMember(p => p.name, opt => opt.MapFrom(p => p.Name));

            AutoMapper.Mapper.CreateMap<Product, DataAvail.UralAppModel.Product>()
                .ForMember(p => p.Id, opt => opt.MapFrom(p => p.id))
                .ForMember(p => p.Name, opt => opt.MapFrom(p => p.name));

            Product product = new Product { id = 0, name = "hip" };

            using (var model = new UralAppModel.Model())
            {
                ProductRepository repo = new ProductRepository();

                repo.SetContext(model);

                repo.GetAll(new Microsoft.Data.Services.Toolkit.QueryModel.ODataQueryOperation());

                repo.Save(product);
            }


            /*
            UralAppServ.DataServiceProvider prr = new UralAppServ.DataServiceProvider(new Uri(@"http://localhost:3360/Service.svc/"));
            var r = prr.Products.Where(p => p.id == 0).First();
            r.name = "nill";
            //prr.AttachTo("Products", r);
            prr.UpdateObject(r);
            prr.SaveChanges();
             */
        }
开发者ID:data-avail,项目名称:DataAvail.Framework,代码行数:35,代码来源:UralAppServiceTest.cs

示例2: IsAvailableTest

 public void IsAvailableTest()
 {
     Program.ClearInformation();
     IRepository<Product> _productRepository = new ProductRepository();
     Product product = new Product(1, "House", "MOPRa,1", "saled");
     _productRepository.Save(product);
     bool actual = Realtor.IsAvailable(product);
     bool expected = false;
     Assert.AreEqual(expected, actual);
     Program.ClearInformation();
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:11,代码来源:Tests.cs

示例3: DealTest

 public void DealTest()
 {
     Program.ClearInformation();
     IRepository<Product> _productRepository = new ProductRepository();
     Product dealingProduct = new Product(1, "House", "MOPRa,1", "for sale");
     _productRepository.Save(dealingProduct);
     Realtor.Deal(_productRepository, dealingProduct.id);
     Product expected = new Product(1, "House", "MOPRa,1", "saled");
     Product actual = _productRepository.GetItem(dealingProduct.id);
     Assert.AreEqual(true, true);
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:11,代码来源:Tests.cs

示例4: Main

        public static void Main(string[] args)
        {
            SessionManager.DomainAssembly = (typeof(Product).Assembly);

            Console.WriteLine("Crear esquema de DB? S/N");
            string ret = Console.ReadLine();
            if(ret.ToUpper() == "S")
                new SchemaExport(SessionManager.Configuration())
                    .Execute(true, true, false);
                //new SchemaUpdate(cfg).Execute();

            IRepository<Product> repository = new ProductRepository(SessionManager.Session());

            Product product = new Product() {
                    Name = "MacBook Pro",
                    //Category = "Computer",∂
                    Price = 1700m,
                    Description = "Aluminum MBP"};

                repository.Save(product);

            //Product productDB = session.Get<Product>(1);

            //TotalProduct Name, TotalUnits, TotalAmount

            // Ejemplo con NHibernate donde se use projections

            // http://blogs.hibernatingrhinos.com/

            //IList<Product> products = repository.FindByProperty("Name", "MacBook Pro");

            //Console.WriteLine(String.Format("Name = {0}, Price = {1}",
            //                                products[0].Name, products[0].Price));

            var projection = Projections.ProjectionList()
                .Add(Projections.Property("Name"), "Nombre")
                .Add(Projections.Property("Price"), "Precio")
                .Add(Projections.Constant(1), "TipoProducto");

            var criteria = SessionManager.Session().CreateCriteria<Product>()
                .Add(Expression.Ge("Price", 100m))
                .AddOrder(Order.Asc("Name"));

            criteria.SetProjection(Projections.Distinct(projection))
                .SetResultTransformer(
                                      NHibernate.Transform.Transformers.AliasToBean(
                                                                                    typeof(ProductDTO)));

            IList<ProductDTO> productos = criteria.List<ProductDTO>();

            SessionManager.Close();
        }
开发者ID:mariochavez,项目名称:Cesun-AppDistribuidas,代码行数:52,代码来源:Main.cs

示例5: AutoFilling

        static void AutoFilling()
        {
            Product[] product = new Product[10];
            Client[] client = new Client[10];
            Manager[] manager = new Manager[10];

            product[0] = new Product(1, "House", "Moskovskaya, 320", "for sale");
            product[1] = new Product(2, "Office", "MOPRa, 30", "for sale");
            product[2] = new Product(3, "House", "Belorusskaya, 10", "for sale");
            product[3] = new Product(4, "Bar", "MOPRa, 3", "for sale");
            product[4] = new Product(5, "House", "Leningradskaya, 35", "for sale");
            product[5] = new Product(6, "Cafe", "Molodogvardeiskaya, 70", "for sale");
            product[6] = new Product(7, "House", "Moskovskaya, 30", "for sale");
            product[7] = new Product(8, "Club", "Zelenaya, 11", "for sale");
            product[8] = new Product(9, "House", "Lugivaja, 11", "for sale");
            product[9] = new Product(10, "Pizzeria", "Pionerskaya, 4", "for sale");

            client[0] = new Client(1, "Fedor Dvinyatin");
            client[1] = new Client(2, "Alexei Volkov");
            client[2] = new Client(3, "Ivan Ivanov");
            client[3] = new Client(4, "Petr Bojko");
            client[4] = new Client(5, "Egor Valedinsky");
            client[5] = new Client(6, "Alexander Evtuh");
            client[6] = new Client(7, "Alexei Lohnitsky");
            client[7] = new Client(8, "Mokin Alexander");
            client[8] = new Client(9, "Pavlovets Sergey");
            client[9] = new Client(10, "Igor Pujko");

            manager[0] = new Manager(1, "Viktor Oniskevich");
            manager[1] = new Manager(2, "Petr Glinskij");
            manager[2] = new Manager(3, "Fedor Yakubuk");
            manager[3] = new Manager(4, "Vasily Sapon");
            manager[4] = new Manager(5, "Igor Ivanovskiy");
            manager[5] = new Manager(6, "Alexander Dubrovsky");
            manager[6] = new Manager(7, "Olga Golub");
            manager[7] = new Manager(8, "Egor Pirozhkov");
            manager[8] = new Manager(9, "Boris Zhukovich");
            manager[9] = new Manager(10, "Igor Stepanchuk");

            IRepository<Client> _clientRepository = new ClientRepository();
            IRepository<Product> _productRepository = new ProductRepository();
            IRepository<Manager> _managerRepository = new ManagerRepository();

            for (int  i=0 ; i<=9 ; i++)
            {
                _clientRepository.Save(client[i]);
                _productRepository.Save(product[i]);
                _managerRepository.Save(manager[i]);
            }
        }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:50,代码来源:Program.cs

示例6: Post

        // POST: api/Products
        public IHttpActionResult Post([FromBody]Product product)
        {
            if (product == null)
            {
                return BadRequest("Product cannot be null");
            }

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var repo = new ProductRepository();
            var newProduct = repo.Save(product);
            if (newProduct == null)
            {
                return Conflict();
            }

            return Created(Url.Link("DefaultApi", new { controller = "Products", id = newProduct.ProductId }), newProduct);
        }
开发者ID:yanivps,项目名称:WebApi-Angular-APM,代码行数:22,代码来源:ProductsController.cs

示例7: Post

        // POST: api/Products
        public IHttpActionResult Post([FromBody]Product product)
        {
            if (product == null)
            {
                return BadRequest("Product cannot be null");
            }

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var productRepository = new ProductRepository();
            var newProduct = productRepository.Save(product);

            if (newProduct == null)
            {
                return Conflict();
            }

            return Created(Request.RequestUri + newProduct.ProductId.ToString(), newProduct);
        }
开发者ID:alexandrupero,项目名称:product-management,代码行数:23,代码来源:ProductsController.cs

示例8: Put

        public IHttpActionResult Put(int id, [FromBody]Product product)
        {
            try
            {
                if (product == null)
                {
                    return BadRequest("Product cannot be null");
                }
                if (!ModelState.IsValid)
                {
                    return BadRequest(ModelState);
                }
                var productRepository = new ProductRepository();
                var updatedProduct = productRepository.Save(id, product);
                if (updatedProduct == null)
                {
                    return NotFound();
                }
                return Ok();
            }
            catch (Exception ex)
            {

                return InternalServerError(ex);
            }
        }
开发者ID:nandotech,项目名称:umgbeta,代码行数:26,代码来源:ProductsController.cs

示例9: Main

        static void Main(string[] args)
        {
            var dataContext = new ApplicationContext("CustomerDataContext");

            // 1) Customers
            var customerRepository = new Repository<Customer, int>(dataContext);

            customerRepository.Insert(new Customer() { Firstname = "Ulla", Lastname = "Bulla" });
            customerRepository.Insert(new Customer() { Firstname = "Tora", Lastname = "Dora" });
            customerRepository.Save();

            var allCustomers = customerRepository.GetAll().ToList();
            foreach (var customer in allCustomers)
            {
                System.Console.WriteLine("Id: {0} Name: {1}", customer.Id, customer.Firstname);
            }

            var last = allCustomers.Last();
            customerRepository.Delete(last.Id);
            customerRepository.Save();

            allCustomers = customerRepository.GetAll().ToList();
            foreach (var customer in allCustomers)
            {
                System.Console.WriteLine("Id: {0} Name: {1}", customer.Id, customer.Firstname);
            }

            System.Console.WriteLine("**************************************");

            // 2) Orders
            var orderCustomer = allCustomers.Last();
            var orderRepository = new Repository<Order, int>(dataContext);

            orderRepository.Insert(new Order() { Date = DateTime.Now, Customer = orderCustomer });
            orderRepository.Save();

            var allOrders = orderRepository.GetAll().ToList();
            foreach (var order in allOrders)
            {
                System.Console.WriteLine(
                    "Id: {0} Order Date: {1} Customer: {2}",
                    order.Id,
                    order.Date.ToShortDateString(),
                    order.Customer.Firstname);
            }

            // 3) Extended Products
            var productRepository = new ProductRepository(dataContext);

            productRepository.Insert(new Product() { Description = "A green bike", Name = "Scott", SKU = "1234567-890" });
            productRepository.Save();

            var foundProducts = productRepository.FindByDescription("green");
            foreach (var product in foundProducts)
            {
                System.Console.WriteLine("Id: {0} Name: {1} Description: {2}",
                    product.Id,
                    product.Name,
                    product.Description);
            }

            System.Console.ReadLine();
        }
开发者ID:Jusuf,项目名称:Design-Patterns,代码行数:63,代码来源:Program.cs

示例10: SyncTable_Product

        /// <summary>
        /// Sync logic for product table
        /// </summary>
        private void SyncTable_Product()
        {
            var localTable = new ProductRepository<Product>(_localSessionContext);
            var remoteTable = new ProductRepository<Product>(_remoteSessionContext);

            OnSyncStart?.Invoke(this, new SyncStartedArgs("Product"));

            #region SyncCode

            var count = 0;
            var total = localTable.Count();
            foreach (var row in localTable.GetAll())
            {

                // Copy object and save (this removes ID)
                var newObject = ObjectCopy.Copy(row);
                remoteTable.Save(newObject);

                // Save changes to remote
                remoteTable.Commit();

                // Create a sync record this captures the remote ID value
                // so we can update any relationships...
                var record = new SyncRecord();
                record.Table_Id = "product_table";
                record.Local_Id = row.Id;
                record.Remote_Id = newObject.Id;
                _recordRepository.Save(record);
                _recordRepository.Commit();

                OnUpdateStatus?.Invoke(this, new ProgressEventArgs("Synced entity " + ++count + "/" + total));

                // Remove after successful remove
                localTable.Remove(row);
                localTable.Commit();
            }

            #endregion
        }
开发者ID:looterwar,项目名称:RepositoryResearch,代码行数:42,代码来源:SyncManager.cs

示例11: EditProductJustDocument

        public void EditProductJustDocument()
        {
            var inizio = DateTime.Now;

            IDocumentRepository docRep = new DocumentRepository();
            IProductRepository prodRep = new ProductRepository();

            PapiroService p = new PapiroService();
            p.DocumentRepository = docRep;
            p.CostDetailRepository = new CostDetailRepository();
            p.TaskExecutorRepository = new TaskExecutorRepository();
            p.ArticleRepository = new ArticleRepository();

            Document doc = docRep.GetEstimateEcommerce("000001");
            doc.EstimateNumber = "0";

            DocumentProduct dp = docRep.GetDocumentProductsByCodProduct("").FirstOrDefault();

            //work with product
            Product prod = p.InitProduct("SuppRigidi", new ProductTaskNameRepository(), new FormatsNameRepository(), new TypeOfTaskRepository());

            //------passaggio del prodotto inizializzato all'ecommerce o alla view
            prod.CodProduct = prodRep.GetNewCode(prod);
            prod.ProductParts.FirstOrDefault().Format = "15x21";
            prod.ProductParts.FirstOrDefault().SubjectNumber = 1;

            var art = prod.ProductParts.FirstOrDefault().ProductPartPrintableArticles.FirstOrDefault();

            #region Printable Article

            IArticleRepository artRep = new ArticleRepository();
            var artFormList = artRep.GetAll().OfType<RigidPrintableArticle>().FirstOrDefault();

            art.TypeOfMaterial = artFormList.TypeOfMaterial;
            art.NameOfMaterial = artFormList.NameOfMaterial;
            art.Weight = artFormList.Weight;
            art.Color = artFormList.Color;
            #endregion

            //------ritorno del prodotto modificato!!!!

            //rigenero
            prodRep.Add(prod);
            prodRep.Save();

            #region ViewModel
            ProductViewModel pv = new ProductViewModel();
            pv.Product = prod;
            //            prod.ProductCodeRigen();

            pv.Quantity = 10;
            #endregion

            p.EditOrCreateAllCost(dp.CodDocumentProduct);

            var fine = DateTime.Now.Subtract(inizio).TotalSeconds;

            Assert.IsTrue(fine < 4);
        }
开发者ID:algola,项目名称:backup,代码行数:59,代码来源:RigidTest.cs

示例12: RepositoryUpdateTest

 public void RepositoryUpdateTest()
 {
     Program.ClearInformation();
     IRepository<Product> _productRepository = new ProductRepository();
     Product product = new Product(1, "House", "MOPRa,1", "for sale");
     _productRepository.Save(product);
     product.status = "saled";
     _productRepository.Update(product);
     Product actual = _productRepository.GetItem(product.id);
     Product expected = new Product(1, "House", "MOPRa,1", "saled");
     Assert.AreEqual(actual.id, product.id);
     Assert.AreEqual(actual.name, product.name);
     Assert.AreEqual(actual.status, product.status);
     Assert.AreEqual(actual.address, product.address);
     Program.ClearInformation();
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:16,代码来源:Tests.cs

示例13: RepositoryRemoveTest

 public void RepositoryRemoveTest()
 {
     Program.ClearInformation();
     IRepository<Product> _productRepository = new ProductRepository();
     Product product = new Product(1, "House", "MOPRa,1", "for sale");
     _productRepository.Save(product);
     _productRepository.Remove(product.id);
     Product actual =  _productRepository.GetItem(product.id);
     Product expected = null;
     Assert.AreEqual(expected, actual);
     Program.ClearInformation();
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:12,代码来源:Tests.cs

示例14: Put

        // PUT: api/Products/5
        public IHttpActionResult Put(int id, [FromBody]Product product)
        {
            if (product == null)
            {
                return BadRequest("Product cannot be null");
            }

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var repo = new ProductRepository();
            var updatedProduct = repo.Save(id, product);
            if (updatedProduct == null)
            {
                return NotFound();
            }

            return Ok();
        }
开发者ID:yanivps,项目名称:WebApi-Angular-APM,代码行数:22,代码来源:ProductsController.cs

示例15: Post

        public IHttpActionResult Post([FromBody]Product product)
        {
            try
            {
                if (product == null)
                {
                    return BadRequest("Product cannot be null");
                }
                if(!ModelState.IsValid)
                {
                    return BadRequest(ModelState);
                }
                var productRepository = new ProductRepository();
                var newProduct = productRepository.Save(product);
                if (newProduct == null)
                {
                    return Conflict();
                }
                return Created<Product>(Request.RequestUri + newProduct.ProductId.ToString(),
                    newProduct);
            }
            catch (Exception ex)
            {

                return InternalServerError(ex);
            }
        }
开发者ID:nandotech,项目名称:umgbeta,代码行数:27,代码来源:ProductsController.cs


注:本文中的ProductRepository.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。