Beispiel #1
0
 public string PostDriverDetails(DriverDetails dtls)
 {
     try
     {
         if (!cabODbContext.Driver.Any(r => r.PhoneNo == dtls.PhoneNo && r.IsDeleted == false))
         {
             var user = new Driver
             {
                 Name      = dtls.Name,
                 PhoneNo   = dtls.PhoneNo,
                 UserName  = dtls.UserName,
                 Password  = dtls.Password,
                 IsDeleted = dtls.IsDeleted
             };
             cabODbContext.Driver.Add(user);
             cabODbContext.SaveChanges();
             return("Posted");
         }
         else
         {
             throw new Exception();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public int AddOfficeCommutation(OfficeCommutationDto officeDto)
 {
     try
     {
         int insertedId = 0;
         if (!cabODbContext.OfficeCommutation.Any(x => x.Location1 == Int32.Parse(officeDto.Location1) && x.Location2 == Int32.Parse(officeDto.Location2) && x.IsDeleted == false))
         {
             var commutation = new OfficeCommutation
             {
                 Location1 = Int32.Parse(officeDto.Location1),
                 Location2 = Int32.Parse(officeDto.Location2),
                 CabId     = Int32.Parse(officeDto.CabId),
                 IsDeleted = false
             };
             cabODbContext.OfficeCommutation.Add(commutation);
             cabODbContext.SaveChanges();
             insertedId = commutation.Id;
         }
         return(insertedId);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public int AddCab(cabdto cabdetails)
        {
            try
            {
                if (!_context.Cab.Any(r => r.VehicleNo == cabdetails.VehicleNo && r.IsDeleted == false))
                {
                    var CabDetail = new Cab
                    {
                        Capacity  = Int32.Parse(cabdetails.Capacity),
                        Model     = cabdetails.Model,
                        VehicleNo = cabdetails.VehicleNo
                    };
                    _context.Cab.Add(CabDetail);
                    _context.SaveChanges();
                }
                else
                {
                    throw new Exception();
                }

                return(1);
            }
            catch (Exception e)
            {
                throw  e;
            }
        }
        public int AddRide(RideAssignmentDto rideDto)
        {
            try
            {
                int value    = 0;
                var days     = rideDto.Days;
                int i        = 0;
                var rideList = cabODbContext.RideAssignment;
                List <RideAssignment> store = new List <RideAssignment>();
                while (i < days)
                {
                    var ddate = rideDto.DailyDate.AddDays(i);

                    if ((!cabODbContext.RideAssignment.Any(x => x.ShiftId == Convert.ToInt32(rideDto.ShiftId) &&
                                                           x.DailyDate.Date == ddate.Date &&
                                                           x.IsDeleted == false && (x.DriverId == Convert.ToInt32(rideDto.DriverId) || x.CabId == Convert.ToInt32(rideDto.CabId)))))
                    {
                        var rides = new RideAssignment
                        {
                            DailyDate = rideDto.DailyDate.AddDays(i),
                            DriverId  = Int32.Parse(rideDto.DriverId),
                            CabId     = Int32.Parse(rideDto.CabId),
                            ShiftId   = Int32.Parse(rideDto.ShiftId),
                            IsDeleted = false
                        };
                        store.Add(rides);
                        value = 1;
                    }
                    else
                    {
                        value = 0;
                    }
                    i++;
                }
                cabODbContext.RideAssignment.AddRange(store);
                cabODbContext.SaveChanges();
                return(value);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public int AddLocation(OfficeLocationDto location)
        {
            try
            {
                int insertedId = 0;
                if (!_context.OfficeLocation.Any(r => r.Address == location.Address && r.IsDeleted == false))
                {
                    var office_location = new OfficeLocation
                    {
                        Address = location.Address
                    };
                    _context.OfficeLocation.Add(office_location);
                    _context.SaveChanges();
                    insertedId = office_location.Id;
                }
                return(insertedId);
            }

            catch
            {
                return(0);
            }
        }
Beispiel #6
0
 public bool addRating(RatingInfo rating)
 {
     try
     {
         var    rideId     = cabODbContext.Ride.FirstOrDefault(r => r.Guid == rating.rideId).Id;
         Rating ratingData = new Rating {
             RideId    = rideId,
             Timing    = rating.timing,
             Behaviour = rating.behaviour,
             Overall   = rating.overall,
             Comments  = rating.comments
         };
         cabODbContext.Rating.Add(ratingData);
         cabODbContext.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         throw e;
     }
 }