Exemplo n.º 1
0
        public LeaseDto GenerateLeaseDto(Lease leaseItem)
        {
            LeaseDto lease = new LeaseDto();

            lease.Id = leaseItem.Id;
            lease.CarLicensePlate          = leaseItem.Car.LicensePlate;
            lease.CarName                  = leaseItem.Car.Title;
            lease.CarOwner                 = leaseItem.Car.Owner.UserName;
            lease.CarPicture               = leaseItem.Car.Picture;
            lease.Status                   = leaseItem.Status;
            lease.latitudePickUpLocation   = (double)leaseItem.PickupLocation.Location.Latitude;
            lease.longtitudePickUpLocation = (double)leaseItem.PickupLocation.Location.Longitude;
            lease.PicUpLocationPictures    = leaseItem.PickupLocation.Pictures;

            switch (lease.Status)
            {
            case LeaseStatus.Rented:
                lease.LeaserUserName = leaseItem.Leaser.UserName;
                break;

            case LeaseStatus.Delivered:
                lease.LeaserUserName             = leaseItem.Leaser.UserName;
                lease.latitudeDeliveryLocation   = (double)leaseItem.DeliveryLocation.Location.Latitude;
                lease.longtitudeDeliveryLocation = (double)leaseItem.DeliveryLocation.Location.Longitude;
                lease.DeliveryLocationPictures   = leaseItem.DeliveryLocation.Pictures;
                break;

            default:
                break;
            }

            return(lease);
        }
Exemplo n.º 2
0
        public IHttpActionResult GetLease(string RegNr)
        {
            var lease = Db.Leases
                        .Where(l => l.Car.LicensePlate == RegNr)
                        .Select(l => new LeaseDto
            {
                CarLicensePlate          = l.Car.LicensePlate,
                CarName                  = l.Car.Title,
                CarOwner                 = l.Car.Owner.UserName,
                latitudePickUpLocation   = (double)l.PickupLocation.Location.Latitude,
                longtitudePickUpLocation = (double)l.PickupLocation.Location.Longitude,
                PicUpLocationPictures    = l.PickupLocation.Pictures,
                CarPicture               = l.Car.Picture,
                Status = l.Status
            }).ToArray();

            if (lease.Count() == 0)
            {
                var emptyLease = new LeaseDto
                {
                    CarLicensePlate = RegNr,
                    Status          = LeaseStatus.Verified
                };
                return(Ok(emptyLease));
            }

            return(Ok(lease.Last()));
        }
Exemplo n.º 3
0
 public void LeaseDelete(LeaseDto dto)
 {
     try
     {
         using (var db = new ONRRDatabaseEntities())
         {
             db.LeasesDelete(dto.LeaseID);
         }
     }
     catch (Exception ex)
     {
         log.Error(ex.Message + Environment.NewLine + ex.StackTrace);
         throw;
     }
 }
Exemplo n.º 4
0
 public void LeaseUpdate(LeaseDto dto)
 {
     try
     {
         using (var db = new ONRRDatabaseEntities())
         {
             db.LeasesUpdate(dto.LeaseID, dto.ONRRLeaseID, dto.BLMSerialNumber,
                             dto.QEPLeaseID, dto.QEPLeaseName, dto.LeaseClassificationID,
                             dto.BIAClassificationID, dto.QEPEffectiveDate, dto.StateCode, dto.County,
                             dto.RoyaltyRate, dto.EffectiveFrom, dto.EffectiveTo, dto.CompanyID);
         }
     }
     catch (Exception ex)
     {
         log.Error(ex.Message + Environment.NewLine + ex.StackTrace);
         throw;
     }
 }
Exemplo n.º 5
0
        public void LeaseCreate(LeaseDto dto)
        {
            try
            {
                using (var db = new ONRRDatabaseEntities())
                {
                    var newId = new ObjectParameter("newId", 0);

                    var id = db.LeasesInsert(dto.ONRRLeaseID, dto.BLMSerialNumber,
                                             dto.QEPLeaseID, dto.QEPLeaseName, dto.LeaseClassificationID,
                                             dto.BIAClassificationID, dto.QEPEffectiveDate, dto.StateCode, dto.County,
                                             dto.RoyaltyRate, dto.EffectiveFrom, dto.EffectiveTo, dto.CompanyID, newId);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                throw;
            }
        }