示例#1
0
        public IHttpActionResult DriverRatingDetails(DriverRating driverRating)
        {
            var DriverRating = new DriverBO().SaveDriverRating(driverRating);

            if (DriverRating)
            {
                return(Ok(DriverRating));
            }
            else
            {
                return(NotFound());
            }
        }
示例#2
0
        public IHttpActionResult DriverRatingDetails(DriverRating driverRating)
        {
            var DriverRating = new DriverBO().SaveDriverRating(driverRating);

            if (DriverRating)
            {
                return(Ok(new { DriverRating }));
            }
            else
            {
                return(Ok(new { Status = UTILITY.FAILURESTATUS }));
            }
        }
示例#3
0
        public IContract GetDriverRating <T>(IContract lookupItem) where T : IContract
        {
            var item = ((DriverRating)lookupItem);

            DriverRating driverItem = db.ExecuteSprocAccessor(DBRoutine.SELECTDRIVERAVERAGERATING,
                                                              MapBuilder <DriverRating>
                                                              .MapAllProperties().Build(), item.DriverID).FirstOrDefault();

            if (driverItem == null)
            {
                return(null);
            }
            return(driverItem);
        }
示例#4
0
        public bool SaveDriverRating <T>(T item) where T : IContract
        {
            var          result       = 0;
            DriverRating driverRating = (DriverRating)(object)item;

            if (currentTransaction == null)
            {
                connection = db.CreateConnection();
                connection.Open();
            }

            var transaction = (currentTransaction == null ? connection.BeginTransaction() : currentTransaction);

            try
            {
                var savecommand = db.GetStoredProcCommand(DBRoutine.SAVEDRIVERRATING);
                db.AddInParameter(savecommand, "BookingNo", System.Data.DbType.String, driverRating.BookingNo);
                db.AddInParameter(savecommand, "DriverID", System.Data.DbType.String, driverRating.DriverID);
                db.AddInParameter(savecommand, "Rating", System.Data.DbType.String, driverRating.Rating);
                db.AddInParameter(savecommand, "Remarks", System.Data.DbType.String, driverRating.Remarks);

                result = db.ExecuteNonQuery(savecommand, transaction);

                if (currentTransaction == null)
                {
                    transaction.Commit();
                }
            }
            catch (Exception ex)
            {
                if (currentTransaction == null)
                {
                    transaction.Rollback();
                }

                throw ex;
            }
            finally
            {
                transaction.Dispose();
                connection.Close();
            }

            return(result > 0 ? true : false);
        }
示例#5
0
        public bool CreateDriverRating(DriverRatingCreate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =

                    new DriverRating()
                {
                    ApplicationUser         = _userId,
                    DriverId                = model.DriverId,
                    DriverFunScore          = model.DriverFunScore,
                    DriverSafetyScore       = model.DriverSafetyScore,
                    DriverCleanlinessScore  = model.DriverCleanlinessScore,
                    UserCreatedDriverRating = ctx.Users.Single(dr => dr.Id == _userId.ToString()).UserName,
                };

                ctx.DriverRatings.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public async Task <int> SeedDriversRatings(ApplicationDbContext context)
        {
            var driversRatings = new DriverRating[]
            {
                new DriverRating()
                {
                    ClientId = "dta", TransferId = 1, DriverId = "abc"
                },
                new DriverRating()
                {
                    ClientId = "dta", TransferId = 2, DriverId = "abc"
                },
                new DriverRating()
                {
                    ClientId = "dta", TransferId = 3, DriverId = "abc"
                },
                new DriverRating()
                {
                    ClientId = "dta", TransferId = 4, DriverId = "bcd"
                },
                new DriverRating()
                {
                    ClientId = "dta", TransferId = 5, DriverId = "bcd"
                },
                new DriverRating()
                {
                    ClientId = "dta", TransferId = 6, DriverId = "cde"
                },
            };

            foreach (var driverRating in driversRatings)
            {
                await context.DriversRatings.AddAsync(driverRating);
            }

            await context.SaveChangesAsync();

            return(driversRatings.Length);
        }
示例#7
0
 public bool SaveDriverRating(DriverRating driverRating)
 {
     return(driverDAL.SaveDriverRating(driverRating));
 }
示例#8
0
 public DriverRating GetDriverRating(DriverRating item)
 {
     return((DriverRating)driverDAL.GetDriverRating <DriverRating>(item));
 }