コード例 #1
0
 /// <summary>
 /// Creates and object with specefied values adn calls the base class.
 /// </summary>
 /// <param name="regNumber">String of regnumber of vehicle</param>
 /// <param name="brand">string brand name of vehicle</param>
 /// <param name="modelYear">string with model year of behicle</param>
 /// <param name="owner">Owner object of vehicle</param>
 /// <param name="doors">int numbers of doors on vehicle</param>
 /// <param name="tires">int number of tires on vehicle</param>
 /// <param name="liftType">LifType needed for vehicle</param>
 /// <param name="height">int height of vehicle</param>
 public Car(string regNumber, string brand, string modelYear, Owner owner, int doors, int tires, LiftType liftType, double height) : base(regNumber, brand, modelYear, owner)
 {
     this.doors    = doors;
     this.tires    = tires;
     this.liftType = liftType;
     this.height   = height;
 }
コード例 #2
0
        private string GetMethodNameForLift(LiftType liftType, int argumentCount)
        {
            if (argumentCount == 1 && liftType == LiftType.Regular)
            {
                return("lift1");
            }

            if (argumentCount == 2)
            {
                switch (liftType)
                {
                case LiftType.Regular:
                    return("lift2");

                case LiftType.Comparison:
                    return("liftcmp");

                case LiftType.Equality:
                    return("lifteq");

                case LiftType.Inequality:
                    return("liftne");
                }
            }

            throw new ArgumentException("Invalid liftType " + liftType + " for " + argumentCount + " arguments");
        }
コード例 #3
0
        public async Task <bool> CreateAsync(string userId, LiftType liftType, int numberOfStops, int capacity, DoorType doorType, string manufacturerId, string productionNumber, string cityId, string address)
        {
            var currentLift = this.liftRepository.All().FirstOrDefault(x => x.ProductionNumber == productionNumber);

            var isCreate = false;

            if (currentLift == null)
            {
                var currentNumber = (this.liftRepository.AllWithDeleted().Count() + 1).ToString();

                var lift = new Lift
                {
                    ApplicationUserId  = userId,
                    RegistrationNumber = "777АС" + currentNumber,
                    LiftType           = liftType,
                    NumberOfStops      = numberOfStops,
                    Capacity           = capacity,
                    DoorType           = doorType,
                    ManufacturerId     = manufacturerId,
                    ProductionNumber   = productionNumber,
                    CityId             = cityId,
                    Address            = address,
                };

                await this.liftRepository.AddAsync(lift);

                await this.liftRepository.SaveChangesAsync();

                isCreate = true;
            }

            return(isCreate);
        }
コード例 #4
0
        public DependencyInjectionAttribute(Type service, LiftType Lifetime = LiftType.Transient, int Priority = 1)
        {
            this.Service = service;

            this.Lifetime = Lifetime;

            this.Priority = Priority;
        }
コード例 #5
0
        public async Task <LiftViewModel> UpdateAsync(LiftViewModel lift, string uid)
        {
            /*
             * Update lift and call GetAll to retrieve the updated lifts
             */
            //var vm = new LiftViewModel();
            Lift     l           = _liftRepository.Get(lift.Lift.Id, uid);
            LiftName liftName    = _liftNameRepository.GetByName(lift.LiftName);
            LiftType liftType    = _liftTypeRepository.GetByName(lift.LiftType);
            var      updatedLift = await _liftRepository.UpdateAsync(l, uid);

            return(LiftMapper.MapLiftToViewModel(updatedLift, uid));//, liftName, liftType, uid);
        }
コード例 #6
0
 public async Task <LiftType> CreateAsync(LiftType liftType)
 {
     try
     {
         await _context.LiftTypes.AddAsync(liftType);
     }
     catch (Exception ex)
     {
         // logging
         return(liftType);
     }
     return(liftType);
 }
コード例 #7
0
 public async Task <LiftType> UpdateAsync(LiftType liftType)
 {
     try
     {
         _context.Entry(liftType).State = EntityState.Modified;
         await _context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         // logging
         return(liftType);
     }
     return(liftType);
 }
コード例 #8
0
        public LiftViewModel Get(string id, string uid)
        {
            Lift     lift     = _liftRepository.Get(id, uid);
            LiftName liftName = _liftNameRepository.Get(lift.LiftName.Id);
            LiftType liftType = _liftTypeRepository.Get(lift.LiftType.Id);

            LiftViewModel viewModel = LiftMapper.MapLiftToViewModel(lift, uid);//,

            //liftName,
            //liftType,
            //uid);

            return(viewModel);
        }
コード例 #9
0
        public async Task <LiftViewModel> CreateAsync(LiftViewModel viewModel, string uid)
        {
            /*
             * Create lift and call GetAll to retrieve the updated lifts
             * - Add DaysService call to change Id (int) to String (day)
             */
            LiftName liftName = _liftNameRepository.GetByName(viewModel.LiftName);
            LiftType liftType = _liftTypeRepository.GetByName(viewModel.LiftType);
            Lift     lift     = LiftMapper.MapViewModelToLift(viewModel, uid, liftName, liftType);

            lift = await _liftRepository.CreateAsync(lift, uid);

            return(LiftMapper.MapLiftToViewModel(lift, uid));//, liftName, liftType, uid);
        }
コード例 #10
0
        private static async Task <bool> CreateLiftAsync(ILiftsService liftsService)
        {
            string   userId           = "U1";
            LiftType liftType         = (LiftType)Enum.Parse(typeof(LiftType), "Пътнически");
            int      numberOfStops    = 4;
            int      capacity         = 450;
            DoorType doorType         = (DoorType)Enum.Parse(typeof(DoorType), "АВ");
            string   manufacturerId   = "M1";
            string   productionNumber = "123";
            string   cityId           = "C1";
            string   address          = "A1";

            var isCreated = await liftsService.CreateAsync(userId, liftType, numberOfStops, capacity, doorType, manufacturerId, productionNumber, cityId, address);

            return(isCreated);
        }
コード例 #11
0
		public virtual JsExpression Lift(JsExpression expression, LiftType liftType, IRuntimeContext context) {
			return _prev.Lift(expression, liftType, context);
		}
コード例 #12
0
ファイル: Lift.cs プロジェクト: ryanww/FrameWork
        //===================// Methods //===================//

        /**
         * Method: SetType
         * Access: public
         * @return: void
         * @param: ushort _type
         * Description: Coverts ushort to it's corresponding LiftType enum
         */
        public void SetType(ushort _type)
        {
            type = (LiftType)_type;
        }
コード例 #13
0
 /// <summary>
 /// Emty constructor sets doors and height to 0 and liftype to Light.
 /// </summary>
 public Car() : base()
 {
     this.doors  = 0;
     this.height = 0.0;
     liftType    = LiftType.Light;
 }
コード例 #14
0
 public async Task <LiftType> UpdateAsync(LiftType lift)
 {
     return(await _liftTypeRepository.UpdateAsync(lift));
 }
コード例 #15
0
ファイル: Trailer.cs プロジェクト: zarkroc/GarageShopBooking
 /// <summary>
 /// Creates and object with specefied values and calls the base class.
 /// </summary>
 /// <param name="regNumber">String of regnumber of vehicle</param>
 /// <param name="brand">string brand name of vehicle</param>
 /// <param name="modelYear">string with model year of behicle</param>
 /// <param name="owner">Owner object of vehicle</param>
 /// <param name="tires">int number of tires on vehicle</param>
 /// <param name="liftType">LifType needed for vehicle</param>
 public Trailer(string regNumber, string brand, string modelYear, Owner owner, int tires, LiftType liftType) : base(regNumber, brand, modelYear, owner, liftType)
 {
     this.Tires = tires;
 }
コード例 #16
0
 JsExpression IRuntimeLibrary.Lift(JsExpression expression, LiftType liftType, IRuntimeContext context)
 {
     return(Lift(expression, liftType, context));
 }
コード例 #17
0
 public static Lift MapViewModelToLift(LiftViewModel viewModel, string uid, LiftName liftName, LiftType liftType)
 {
     return(new Lift()
     {
         Id = Guid.NewGuid().ToString(),
         MaxLift = viewModel.MaxLift,
         IsMainLift = viewModel.IsMainLift,
         Date = viewModel.Date,
         UserId = uid,
         LiftName = new LiftName()
         {
             Id = liftName.Id
         },
         LiftType = new LiftType()
         {
             Id = liftType.Id
         }
     });
 }
コード例 #18
0
 /// <summary>
 /// Creates and object with specefied values and calls the base class.
 /// </summary>
 /// <param name="regNumber">String of regnumber of vehicle</param>
 /// <param name="brand">string brand name of vehicle</param>
 /// <param name="modelYear">string with model year of behicle</param>
 /// <param name="owner">Owner object of vehicle</param>
 /// <param name="liftType">LifType needed for vehicle</param>
 public Trailers(string regNumber, string brand, string modelYear, Owner owner, LiftType liftType) : base(regNumber, brand, modelYear, owner)
 {
     this.LiftType = liftType;
 }
コード例 #19
0
        public JsExpression Lift(JsExpression expression, LiftType liftType, IRuntimeContext context)
        {
            if (expression is JsInvocationExpression)
            {
                var ie = (JsInvocationExpression)expression;
                if (ie.Method is JsMemberAccessExpression)
                {
                    var mae = (JsMemberAccessExpression)ie.Method;
                    if (mae.Target is JsTypeReferenceExpression)
                    {
                        var  t             = ((JsTypeReferenceExpression)mae.Target).Type;
                        bool isIntegerType = t.IsKnownType(KnownTypeCode.Byte) || t.IsKnownType(KnownTypeCode.SByte) || t.IsKnownType(KnownTypeCode.Int16) || t.IsKnownType(KnownTypeCode.UInt16) || t.IsKnownType(KnownTypeCode.Char) || t.IsKnownType(KnownTypeCode.Int32) || t.IsKnownType(KnownTypeCode.UInt32) || t.IsKnownType(KnownTypeCode.Int64) || t.IsKnownType(KnownTypeCode.UInt64);
                        if (isIntegerType)
                        {
                            if (mae.MemberName == "div" || mae.MemberName == "trunc")
                            {
                                return(expression);
                            }
                        }
                    }
                }

                return(JsExpression.Invocation(JsExpression.Member(CreateTypeReferenceExpression(KnownTypeReference.NullableOfT), GetMethodNameForLift(liftType, ie.Arguments.Count)), new[] { ie.Method }.Concat(ie.Arguments)));
            }
            if (expression is JsUnaryExpression)
            {
                string methodName = null;
                switch (expression.NodeType)
                {
                case ExpressionNodeType.LogicalNot: methodName = "not"; goto default;

                case ExpressionNodeType.Negate:     methodName = "neg"; goto default;

                case ExpressionNodeType.Positive:   methodName = "pos"; goto default;

                case ExpressionNodeType.BitwiseNot: methodName = "cpl"; goto default;

                default:
                    if (methodName != null)
                    {
                        return(JsExpression.Invocation(JsExpression.Member(CreateTypeReferenceExpression(KnownTypeReference.NullableOfT), methodName), ((JsUnaryExpression)expression).Operand));
                    }
                    break;
                }
            }
            else if (expression is JsBinaryExpression)
            {
                string methodName = null;
                switch (expression.NodeType)
                {
                case ExpressionNodeType.Equal:
                case ExpressionNodeType.Same:
                    methodName = "eq";
                    goto default;

                case ExpressionNodeType.NotEqual:
                case ExpressionNodeType.NotSame:
                    methodName = "ne";
                    goto default;

                case ExpressionNodeType.LesserOrEqual:      methodName = "le";   goto default;

                case ExpressionNodeType.GreaterOrEqual:     methodName = "ge";   goto default;

                case ExpressionNodeType.Lesser:             methodName = "lt";   goto default;

                case ExpressionNodeType.Greater:            methodName = "gt";   goto default;

                case ExpressionNodeType.Subtract:           methodName = "sub";  goto default;

                case ExpressionNodeType.Add:                methodName = "add";  goto default;

                case ExpressionNodeType.Modulo:             methodName = "mod";  goto default;

                case ExpressionNodeType.Divide:             methodName = "div";  goto default;

                case ExpressionNodeType.Multiply:           methodName = "mul";  goto default;

                case ExpressionNodeType.BitwiseAnd:         methodName = "band"; goto default;

                case ExpressionNodeType.BitwiseOr:          methodName = "bor";  goto default;

                case ExpressionNodeType.BitwiseXor:         methodName = "bxor"; goto default;

                case ExpressionNodeType.LeftShift:          methodName = "shl";  goto default;

                case ExpressionNodeType.RightShiftSigned:   methodName = "srs";  goto default;

                case ExpressionNodeType.RightShiftUnsigned: methodName = "sru";  goto default;

                default:
                    if (methodName != null)
                    {
                        return(JsExpression.Invocation(JsExpression.Member(CreateTypeReferenceExpression(KnownTypeReference.NullableOfT), methodName), ((JsBinaryExpression)expression).Left, ((JsBinaryExpression)expression).Right));
                    }
                    break;
                }
            }

            throw new ArgumentException("Cannot lift expression " + OutputFormatter.Format(expression, true));
        }
コード例 #20
0
		public JsExpression Lift(JsExpression expression, LiftType liftType, IRuntimeContext context) {
			if (expression is JsInvocationExpression) {
				var ie = (JsInvocationExpression)expression;
				if (ie.Method is JsMemberAccessExpression) {
					var mae = (JsMemberAccessExpression)ie.Method;
					if (mae.Target is JsTypeReferenceExpression) {
						var t = ((JsTypeReferenceExpression)mae.Target).Type;
						bool isIntegerType = t.IsKnownType(KnownTypeCode.Byte) || t.IsKnownType(KnownTypeCode.SByte) || t.IsKnownType(KnownTypeCode.Int16) || t.IsKnownType(KnownTypeCode.UInt16) || t.IsKnownType(KnownTypeCode.Char) || t.IsKnownType(KnownTypeCode.Int32) || t.IsKnownType(KnownTypeCode.UInt32) || t.IsKnownType(KnownTypeCode.Int64) || t.IsKnownType(KnownTypeCode.UInt64);
						if (isIntegerType) {
							if (mae.MemberName == "div" || mae.MemberName == "trunc")
								return expression;
						}
					}
				}

				return JsExpression.Invocation(JsExpression.Member(CreateTypeReferenceExpression(KnownTypeReference.NullableOfT), GetMethodNameForLift(liftType, ie.Arguments.Count)), new[] { ie.Method }.Concat(ie.Arguments));
			}
			if (expression is JsUnaryExpression) {
				string methodName = null;
				switch (expression.NodeType) {
					case ExpressionNodeType.LogicalNot: methodName = "not"; goto default;
					case ExpressionNodeType.Negate:     methodName = "neg"; goto default;
					case ExpressionNodeType.Positive:   methodName = "pos"; goto default;
					case ExpressionNodeType.BitwiseNot: methodName = "cpl"; goto default;

					default:
						if (methodName != null)
							return JsExpression.Invocation(JsExpression.Member(CreateTypeReferenceExpression(KnownTypeReference.NullableOfT), methodName), ((JsUnaryExpression)expression).Operand);
						break;
				}
			}
			else if (expression is JsBinaryExpression) {
				string methodName = null;
				switch (expression.NodeType) {
					case ExpressionNodeType.Equal:
					case ExpressionNodeType.Same:
						methodName = "eq";
						goto default;

					case ExpressionNodeType.NotEqual:
					case ExpressionNodeType.NotSame:
						methodName = "ne";
						goto default;

					case ExpressionNodeType.LesserOrEqual:      methodName = "le";   goto default;
					case ExpressionNodeType.GreaterOrEqual:     methodName = "ge";   goto default;
					case ExpressionNodeType.Lesser:             methodName = "lt";   goto default;
					case ExpressionNodeType.Greater:            methodName = "gt";   goto default;
					case ExpressionNodeType.Subtract:           methodName = "sub";  goto default;
					case ExpressionNodeType.Add:                methodName = "add";  goto default;
					case ExpressionNodeType.Modulo:             methodName = "mod";  goto default;
					case ExpressionNodeType.Divide:             methodName = "div";  goto default;
					case ExpressionNodeType.Multiply:           methodName = "mul";  goto default;
					case ExpressionNodeType.BitwiseAnd:         methodName = "band"; goto default;
					case ExpressionNodeType.BitwiseOr:          methodName = "bor";  goto default;
					case ExpressionNodeType.BitwiseXor:         methodName = "bxor"; goto default;
					case ExpressionNodeType.LeftShift:          methodName = "shl";  goto default;
					case ExpressionNodeType.RightShiftSigned:   methodName = "srs";  goto default;
					case ExpressionNodeType.RightShiftUnsigned: methodName = "sru";  goto default;

					default:
						if (methodName != null)
							return JsExpression.Invocation(JsExpression.Member(CreateTypeReferenceExpression(KnownTypeReference.NullableOfT), methodName), ((JsBinaryExpression)expression).Left, ((JsBinaryExpression)expression).Right);
						break;
				}
			}

			throw new ArgumentException("Cannot lift expression " + OutputFormatter.Format(expression, true));
		}
コード例 #21
0
 /// <summary>
 /// Empty constructor. Sets doors and tires to 0 and LiftType to Heavy.
 /// </summary>
 public Truck() : base()
 {
     this.doors    = 0;
     this.tires    = 0;
     this.liftType = LiftType.Heavy;
 }
コード例 #22
0
 /// <summary>
 /// Creates an object with specefied values and calls the base class constructor.
 /// </summary>
 /// <param name="regNumber">String of regnumber of vehicle</param>
 /// <param name="brand">string brand name of vehicle</param>
 /// <param name="modelYear">string with model year of behicle</param>
 /// <param name="owner">Owner object of vehicle</param>
 /// <param name="numOfSkids">int number of skids on vehicle</param>
 /// <param name="liftType">LifType needed for vehicle</param>
 public TowedSled(string regNumber, string brand, string modelYear, Owner owner, int numOfSkids, LiftType liftType) : base(regNumber, brand, modelYear, owner, liftType)
 {
     this.NumOfSkids = numOfSkids;
 }
コード例 #23
0
		private string GetMethodNameForLift(LiftType liftType, int argumentCount) {
			if (argumentCount == 1 && liftType == LiftType.Regular)
				return "lift1";

			if (argumentCount == 2) {
				switch (liftType) {
					case LiftType.Regular:
						return "lift2";
					case LiftType.Comparison:
						return "liftcmp";
					case LiftType.Equality:
						return "lifteq";
					case LiftType.Inequality:
						return "liftne";
				}
			}

			throw new ArgumentException("Invalid liftType " + liftType + " for " + argumentCount + " arguments");
		}
コード例 #24
0
 public virtual JsExpression Lift(JsExpression expression, LiftType liftType, IRuntimeContext context)
 {
     return(_prev.Lift(expression, liftType, context));
 }
コード例 #25
0
		JsExpression IRuntimeLibrary.Lift(JsExpression expression, LiftType liftType, IRuntimeContext context) {
			return Lift(expression, liftType, context);
		}