Exemple #1
0
 public static void UpdateEmployee(Employee employee)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempEmployee = db.Employees.Single(x => x.Id == employee.Id);
             tempEmployee.FirstName = employee.FirstName;
             tempEmployee.LastName  = employee.LastName;
             tempEmployee.Title     = employee.Title;
             tempEmployee.BirthDate = employee.BirthDate;
             tempEmployee.HireDate  = employee.HireDate;
             tempEmployee.Address   = employee.Address;
             tempEmployee.City      = employee.City;
             tempEmployee.HomePage  = employee.HomePage;
             tempEmployee.Photo     = employee.Photo;
             tempEmployee.PhotoPath = employee.PhotoPath;
             tempEmployee.ReportTo  = employee.ReportTo;
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:UpdateEmployee " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
        public static async Task <(ResultMessage result, byte[] effectsHash, EffectProcessorsContainer container)> ProcessQuantumIsolated(this IntegrationTestEnvironment environment, MessageEnvelope envelope)
        {
            var context = new AlphaContext(environment.AlphaWrapper.Context.Settings, new MockStorage(), environment.AlphaWrapper.Context.StellarDataProvider);

            await context.Init();

            //wait while all pending updates will be saved
            while (await environment.AlphaWrapper.Context.PersistenceManager.GetLastApex() != environment.AlphaWrapper.Context.QuantumStorage.CurrentApex)
            {
                Thread.Sleep(100);
            }
            await context.Setup(await environment.AlphaWrapper.Context.PersistenceManager.GetSnapshot(environment.AlphaWrapper.Context.QuantumStorage.CurrentApex));

            var messageType = envelope.Message.MessageType;

            if (messageType == MessageTypes.RequestQuantum)
            {
                messageType = ((RequestQuantum)envelope.Message).RequestMessage.MessageType;
            }

            context.QuantumProcessor.TryGetValue(messageType, out var processor);

            var container      = new EffectProcessorsContainer(context, envelope, new DiffObject());
            var processContext = processor.GetContext(container);

            var res = await processor.Process(processContext);

            var effectsHash = new EffectsContainer {
                Effects = container.Effects
            }.ComputeHash();

            return(res, effectsHash, container);
        }
Exemple #3
0
 public static void InsertEmployee(Employee employee)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             db.Employees.Add(employee);
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:InsertEmployee " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Exemple #4
0
 public static void InsertOrderDetail(OrderDetail orderDetail)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             db.OrderDetails.Add(orderDetail);
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:InsertOrderDetail " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Exemple #5
0
 public static void InsertProduct(Product product)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             db.Products.Add(product);
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:InsertProduct " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Exemple #6
0
 public static void InsertCustomer(Customer customer)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             db.Customers.Add(customer);
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:InsertCustomer " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Exemple #7
0
 public static void DeleteCategory(int categoryId)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempCategory = db.Categories.Single(x => x.Id == categoryId);
             db.Categories.Remove(tempCategory);
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:DeleteCategory " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Exemple #8
0
 public static void DeleteOrderDetail(int orderDetailId)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempOrderDetail = db.OrderDetails.Single(x => x.Id == orderDetailId);
             db.OrderDetails.Remove(tempOrderDetail);
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:DeleteOrderDetail " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Exemple #9
0
        public static OrderDetail GetOrderDetailsById(int orderDetailsId)
        {
            var tempOrderDetail = new OrderDetail();

            try
            {
                using (var db = new AlphaContext())
                {
                    tempOrderDetail = db.OrderDetails.Single(x => x.Id == orderDetailsId);
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetOrderDetailsById " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(tempOrderDetail);
        }
Exemple #10
0
 public ActionResult SignUp1(User user)
 {
     using (var db = new AlphaContext())
     {
         var tempUser = db.Users.Single(x => x.Username == user.Username && x.Password == user.Password);
         if (tempUser != null)
         {
             Session["username"] = tempUser.Username.ToList();
             return(RedirectToAction("demo1"));
         }
         else
         {
             ModelState.AddModelError("", "username or password is Incorrect..!");
         }
     }
     return(View());
 }
Exemple #11
0
        public static List <Product> GetAllProducts()
        {
            var productList = new List <Product>();

            try
            {
                using (var db = new AlphaContext())
                {
                    productList = db.Products.ToList();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetAllProducts " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(productList);
        }
Exemple #12
0
        public static List <Employee> GetAllEmployees()
        {
            var employeeList = new List <Employee>();

            try
            {
                using (var db = new AlphaContext())
                {
                    employeeList = db.Employees.ToList();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetAllEmployees " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(employeeList);
        }
Exemple #13
0
        public static List <OrderDetail> GetAllOrderDetails()
        {
            var orderDetailList = new List <OrderDetail>();

            try
            {
                using (var db = new AlphaContext())
                {
                    orderDetailList = db.OrderDetails.ToList();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetAllOrderDetails " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(orderDetailList);
        }
Exemple #14
0
        public static Supplier GetSupplierById(int supplierId)
        {
            var tempSupplier = new Supplier();

            try
            {
                using (var db = new AlphaContext())
                {
                    tempSupplier = db.Suppliers.Single(x => x.Id == supplierId);
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetSupplierById " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(tempSupplier);
        }
Exemple #15
0
        public static List <Order> GetAllOrdersByDate(DateTime fromDate, DateTime toDate)
        {
            var orderList = new List <Order>();

            try
            {
                using (var db = new AlphaContext())
                {
                    orderList = db.Orders.Where(x => Convert.ToDateTime(x.OrderDate) >= fromDate && Convert.ToDateTime(x.OrderDate) <= toDate).ToList();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetAllOrdersByDate " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(orderList);
        }
Exemple #16
0
        public static List <OrderDetail> GetOrderDetailsByOrderId(int orderId)
        {
            var list = new List <OrderDetail>();

            try
            {
                using (var db = new AlphaContext())
                {
                    list = db.OrderDetails.Where(x => x.OrderId == orderId).ToList();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetOrderDetailsByOrderId " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(list);
        }
Exemple #17
0
        public static Product GetProductById(int productId)
        {
            var tempProduct = new Product();

            try
            {
                using (var db = new AlphaContext())
                {
                    tempProduct = db.Products.Single(x => x.Id == productId);
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetProductById " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(tempProduct);
        }
Exemple #18
0
        public static List <Product> GetProductBySupplierId(int supplierId)
        {
            var list = new List <Product>();

            try
            {
                using (var db = new AlphaContext())
                {
                    list = db.Products.Where(x => x.SupplierId == supplierId).ToList();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetProductBySupplierId " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(list);
        }
Exemple #19
0
        public static Employee GetEmployeeById(int employeeId)
        {
            var tempEmployee = new Employee();

            try
            {
                using (var db = new AlphaContext())
                {
                    tempEmployee = db.Employees.Single(x => x.Id == employeeId);
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetEmployeeById " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(tempEmployee);
        }
Exemple #20
0
        public static Category GetCategoryById(int categoryId)
        {
            var tempCategory = new Category();

            try
            {
                using (var db = new AlphaContext())
                {
                    tempCategory = db.Categories.Single(x => x.Id == categoryId);
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetCategoryById " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(tempCategory);
        }
Exemple #21
0
        public static List <Supplier> GetAllSuppliers()
        {
            var supplierList = new List <Supplier>();

            try
            {
                using (var db = new AlphaContext())
                {
                    supplierList = db.Suppliers.ToList();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetAllSuppliers " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(supplierList);
        }
Exemple #22
0
        public static List <Category> GetAllCategories()
        {
            var categoryList = new List <Category>();

            try
            {
                using (var db = new AlphaContext())
                {
                    categoryList = db.Categories.ToList();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:GetAllCategories " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
            return(categoryList);
        }
Exemple #23
0
        public static void DeleteSupplier(int supplierId)
        {
            try
            {
                using (var db = new AlphaContext())
                {
                    var tempSupplier = db.Suppliers.Single(x => x.Id == supplierId);

                    db.Suppliers.Remove(tempSupplier);

                    db.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:DeleteSupplier " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
        }
Exemple #24
0
        public static void DeleteProduct(int productId)
        {
            try
            {
                using (var db = new AlphaContext())
                {
                    var tempProduct = db.Products.Single(x => x.Id == productId);

                    db.Products.Remove(tempProduct);

                    db.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                LogManage.Log("MethodName:DeleteProduct " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
            }
        }
Exemple #25
0
 public static void UpdateCategory(Category category)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempCategory = db.Categories.Single(x => x.Id == category.Id);
             tempCategory.CategoryName = category.CategoryName;
             tempCategory.Description  = category.Description;
             tempCategory.Picture      = category.Picture;
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:UpdateCategory " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Exemple #26
0
 public static void UpdateOrderDetail(OrderDetail orderDetail)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempOrderDetail = db.OrderDetails.Single(x => x.Id == orderDetail.Id);
             tempOrderDetail.ProductId = orderDetail.ProductId;
             tempOrderDetail.Product   = orderDetail.Product;
             tempOrderDetail.UnitPrice = orderDetail.UnitPrice;
             tempOrderDetail.Quantity  = orderDetail.Quantity;
             tempOrderDetail.Discount  = orderDetail.Discount;
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:UpdateOrderDetail " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Exemple #27
0
 public static void UpdateOrder(Order order)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempOrder = db.Orders.Single(x => x.Id == order.Id);
             tempOrder.OrderDate  = order.OrderDate;
             tempOrder.CustomerId = order.CustomerId;
             tempOrder.EmployeeId = order.EmployeeId;
             tempOrder.Employee   = order.Employee;
             tempOrder.Discount   = order.Discount;
             tempOrder.NetTotal   = order.NetTotal;
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:UpdateOrder " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Exemple #28
0
        public static void Initialize(AlphaContext context)
        {
            context.Database.EnsureCreated();

            if (context.Users.Any())
            {
                return;
            }

            var users = new []
            {
                new User("Fercho Administrador", "*****@*****.**", Role.Admin, "Lolita"),
                new User("Pepito destinatario", "*****@*****.**", Role.Destinater, "destinater")
            };

            foreach (var user in users)
            {
                context.Users.Add(user);
            }

            context.SaveChanges();
        }
Exemple #29
0
 public static void UpdateCustomer(Customer customer)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempCustomer = db.Customers.Single(x => x.Id == customer.Id);
             tempCustomer.CompanyName  = customer.CompanyName;
             tempCustomer.ContactName  = customer.CompanyName;
             tempCustomer.ContactTitle = customer.ContactTitle;
             tempCustomer.Address      = customer.Address;
             tempCustomer.City         = customer.City;
             tempCustomer.Phone        = customer.Phone;
             tempCustomer.Fax          = customer.Fax;
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:UpdateCustomer " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
Exemple #30
0
 public static void UpdateProduct(Product product)
 {
     try
     {
         using (var db = new AlphaContext())
         {
             var tempProduct = db.Products.Single(x => x.Id == product.Id);
             tempProduct.Quantity      = product.Quantity;
             tempProduct.ProductName   = product.ProductName;
             tempProduct.Supplier      = product.Supplier;
             tempProduct.CategoryId    = product.CategoryId;
             tempProduct.SupplierId    = product.SupplierId;
             tempProduct.UnitPrice     = product.UnitPrice;
             tempProduct.UnitsInStock  = product.UnitsInStock;
             tempProduct.Discountinued = product.Discountinued;
             db.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogManage.Log("MethodName:UpdateProduct " + Environment.NewLine + " Time: " + DateTime.Now + Environment.NewLine + " ErrorMsg: " + exception.Message);
     }
 }
	public AlphaContext alpha() {
		AlphaContext _localctx = new AlphaContext(Context, State);
		EnterRule(_localctx, 424, RULE_alpha);
		int _la;
		try {
			EnterOuterAlt(_localctx, 1);
			{
			State = 2831;
			_la = TokenStream.La(1);
			if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << A) | (1L << B) | (1L << C) | (1L << D) | (1L << E) | (1L << F) | (1L << G) | (1L << H) | (1L << I) | (1L << J) | (1L << K) | (1L << L) | (1L << M) | (1L << N) | (1L << O) | (1L << P) | (1L << Q) | (1L << R) | (1L << S) | (1L << T) | (1L << U) | (1L << V) | (1L << W) | (1L << X) | (1L << Y) | (1L << Z))) != 0)) ) {
			ErrorHandler.RecoverInline(this);
			}
			else {
			    Consume();
			}
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}