Пример #1
0
 public Order CreateOrder(Order order)
 {
     _context.Orders.Add(order);         /* */
     _context.SaveChanges();
     // /* orderin detayları üzerinde dönüp onları da kaydedeceğiz */
     // foreach(var item in order.OrderDetail)
     // {
     // _context.Orders.Add(item);         /* */
     // _context.SaveChanges();
     // }
     return(order);
 }
Пример #2
0
 public ActionResult <List <ProductPrice> > Create(ProductPrice ProductPrice)
 {
     //_context.ProductPrices.Add(new ProductPrice { ID=id });
     _context.ProductPrices.Add(ProductPrice);
     _context.SaveChanges();
     return(_context.ProductPrices.ToList());
 }
Пример #3
0
 public ActionResult <List <OrderDetail> > Create(OrderDetail OrderDetail)
 {
     //_context.OrderDetails.Add(new OrderDetail { ID=id });
     _context.OrderDetails.Add(OrderDetail);
     _context.SaveChanges();
     return(_context.OrderDetails.ToList());
 }
Пример #4
0
 public ActionResult <List <Supplier> > Create(Supplier Supplier)
 {
     //_context.Suppliers.Add(new Supplier { ID=id });
     _context.Suppliers.Add(Supplier);
     _context.SaveChanges();
     return(_context.Suppliers.ToList());
 }
Пример #5
0
 public ActionResult <List <Customer> > Create(Customer Customer)
 {
     //_context.Customers.Add(new Customer { ID=id });
     _context.Customers.Add(Customer);
     _context.SaveChanges();
     return(_context.Customers.ToList());
 }
Пример #6
0
 public ActionResult <List <Invoice> > Create(Invoice Invoice)
 {
     //_context.Invoices.Add(new Invoice { ID=id });
     _context.Invoices.Add(Invoice);
     _context.SaveChanges();
     return(_context.Invoices.ToList());
 }
Пример #7
0
 public ProductController(MariContext context)
 {
     _context = context;
     if (_context.Products.Count() == 0)
     {
         _context.Products.Add(new Product {
             ID = 1, NameEN = "Dummy", Code = "DUMMY"
         });
         _context.SaveChanges();
     }
 }
Пример #8
0
        public ActionResult <List <Product> > Create(Product product)
        {
            //_context.Products.Add(new Product { ID=id });
            if (_context.Products.Where(x => x.Code == product.Code) != null)
            {
                return(BadRequest(new { message = "Ürün zaten kayıtlı!" }));
            }

            _context.Products.Add(product);
            _context.SaveChanges();
            return(_context.Products.ToList());
        }
Пример #9
0
        public MariUser Create(MariUser user, string password)
        {
            Log.Logger = new LoggerConfiguration()
                         .Enrich.FromLogContext()
                         // .WriteTo.Console()
                         //.WriteTo.Console(new RenderedCompactJsonFormatter())
                         .WriteTo.File(new RenderedCompactJsonFormatter(), "../logs/log.ndjson")
                         .CreateLogger();
            Log.Information("Start User Service Controller");

            //_logger.Information("Start user service Create");
            // validation
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new AppException("Password is required");
            }

            if (_context.MariUsers.Any(x => x.Username == user.Username))
            {
                throw new AppException("Username \"" + user.Username + "\" is already taken");
            }

            byte[] passwordHash, passwordSalt;
            CreatePasswordHash(password, out passwordHash, out passwordSalt);

            user.PasswordHash = passwordHash;
            user.PasswordSalt = passwordSalt;


            //_logger.Information("before EF savechanges in user service Create");
            _context.MariUsers.Add(user);
            _context.SaveChanges();



            return(user);
        }