コード例 #1
0
ファイル: TripRepository.cs プロジェクト: islamosman/FCBE
        public RequestResponse UpdateTripRate(int tripId, int rate, bool isRepair)
        {
            Trips currentTrip = GetById(tripId);

            currentTrip.Rate = byte.Parse(rate.ToString());
            AddUpdate(currentTrip);

            if (isRepair)
            {
                using (VehicleStatusRepository vStatus = new VehicleStatusRepository())
                {
                    VehicleStatus currentVStatusModel = vStatus.GetById(currentTrip.VehicleId);
                    currentVStatusModel.InService = isRepair;

                    vStatus.AddUpdate(currentVStatusModel);
                }
            }
            return(responseObj);
        }
コード例 #2
0
        public override RequestResponse AddUpdate(Vehicles entity)
        {
            Validate(entity);

            if (responseObj.ErrorMessages.Count <= 0)
            {
                if (entity.Id > 0)
                {
                    using (VehicleStatusRepository vStatusRepo = new VehicleStatusRepository())
                    {
                        vStatusRepo.AddUpdate(new VehicleStatus()
                        {
                            AreaId        = entity.VehicleStatus.AreaId,
                            BatteryStatus = entity.VehicleStatus.BatteryStatus,
                            InRide        = entity.VehicleStatus.InRide,
                            InService     = entity.VehicleStatus.InService,
                            LatV          = entity.VehicleStatus.LatV,
                            LongV         = entity.VehicleStatus.LongV,
                            VehicleId     = entity.VehicleStatus.VehicleId,
                            VehicleQR     = entity.VehicleStatus.VehicleQR
                        });

                        vStatusRepo.Save();
                    }

                    using (VehicleSpecsRepository vSpecsRepo = new VehicleSpecsRepository())
                    {
                        vSpecsRepo.AddUpdate(new VehicleSpecs()
                        {
                            VehicleId  = entity.VehicleSpecs.VehicleId,
                            CategoryId = entity.VehicleSpecs.CategoryId,
                            ModelId    = entity.VehicleSpecs.ModelId
                        });

                        vSpecsRepo.Save();
                    }

                    Attach(new Vehicles()
                    {
                        Id        = entity.Id,
                        Name      = entity.Name,
                        PlateNo   = entity.PlateNo,
                        HolderId  = entity.HolderId,
                        IsActive  = entity.IsActive,
                        UniqueId  = entity.UniqueId,
                        ImageName = entity.ImageName
                    });
                }
                else
                {
                    // Generate QR
                    entity.UniqueId  = RandomNumber(10);
                    entity.ImageName = string.IsNullOrEmpty(entity.ImageName) ? "noimage" : entity.ImageName;
                    entity.VehicleStatus.VehicleQR = entity.UniqueId;
                    Add(entity);
                }
                Save();
                responseObj.Messages.Add("succss", OperationLP.SuccessMsg);
            }
            return(responseObj);
        }