示例#1
0
 /// <summary>
 /// Added by Ashwajit Bansod
 /// while editing a driver then getting all the data of that driver
 /// </summary>
 /// <param name="DriverId"></param>
 /// <returns></returns>
 public eFleetDriverModel GetDriverDetailsById(long DriverId)
 {
     try
     {
         var db = new workorderEMSEntities();
         var ObjeFleetDriverRepository = new eFleetDriverRepository();
         var editDriverDetails         = new eFleetDriverModel();
         var objeFleetDriver           = new eFleetDriver();
         var driverDetails             = ObjeFleetDriverRepository.GetSingleOrDefault(u => u.DriverID == DriverId && u.IsDeleted == false);
         if (driverDetails.DriverID > 0)
         {
             //editDriverDetails.Passwordforedit = driverDetails.Password;
             AutoMapper.Mapper.CreateMap <eFleetDriver, eFleetDriverModel>();
             var objfleetVehicleMapper = AutoMapper.Mapper.Map(driverDetails, editDriverDetails);
             editDriverDetails.DriverImage = (from em in db.UserRegistrations where em.UserId == driverDetails.EmployeeName select em.ProfileImage == null ? "" : HostingPrefix + ProfilePicPath.Replace("~", "") + em.ProfileImage).FirstOrDefault();
             //editDriverDetails.DriverImage = driverDetails.DriverImage == null ? "" : HostingPrefix + ProfilePicPath.Replace("~", "") + driverDetails.DriverImage;
             // editDriverDetails.DOBForEdit = driverDetails.DOB;
         }
         return(editDriverDetails);
     }
     catch (Exception ex)
     {
         Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public eFleetDriverModel GetDriverDetailsById(long DriverId)", "Exception While Editing Driver.", null);
         throw;
     }
 }
示例#2
0
        /// <summary>
        /// Created By Ashwajit Bansod Dated : Sept-26-2017
        /// For Fetching only employee records from UserRegistration
        /// </summary>
        /// <returns></returns>
        public List <EmployeeModel> GetAllEmployees(long LocationId, long DriverID)
        {
            try
            {
                workorderEMSEntities objworkorderEMSEntities = new workorderEMSEntities();
                var objeFleetDriverRepository    = new eFleetDriverRepository();
                var objeFleetDriver              = new eFleetDriver();
                List <EmployeeModel> lstEmployee = new List <EmployeeModel>();

                var objGlobalAdminManager = new GlobalAdminManager();
                lstEmployee = objGlobalAdminManager.GetLocationEmployeeforGenericLocServices(LocationId, 190, 4);

                //lstEmployee = objworkorderEMSEntities.UserRegistrations.Where(d => d.IsDeleted == false && d.UserType == 3 ).Select(c => new EmployeeModel()
                //{
                //    FirstName = c.FirstName + " " + c.LastName,
                //    UserId = c.UserId,
                //    ProfileImage = c.ProfileImage == null ? "" : HostingPrefix + ProfilePicPath.Replace("~", "") + c.ProfileImage,
                //    // ProfileImage = c.ProfileImage,
                //    UserType = c.UserType
                //}).ToList();
                var listDriver = objworkorderEMSEntities.eFleetDrivers.Where(x => x.IsDeleted == false && x.LocationID == LocationId).Select(r => new EmployeeModel()
                {
                    FirstName    = r.UserRegistration.FirstName + " " + r.UserRegistration.LastName,
                    UserId       = r.EmployeeName.Value,
                    ProfileImage = r.UserRegistration.ProfileImage == null ? "" : HostingPrefix + ProfilePicPath.Replace("~", "") + r.UserRegistration.ProfileImage,
                    UserType     = r.UserRegistration.UserType
                }).Distinct().ToList();
                var t = lstEmployee.Where(a => !listDriver.Any(b => a.UserId == b.UserId)).ToList();
                return(t);
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public List<EmployeeModel> GetAllEmployees()", "Exception While Getting All Employee.", null);
                throw;
            }
        }
示例#3
0
        /// <summary>
        /// Created by Ashwait Bansod for Saving data to database and also update data to database
        /// </summary>
        /// <param name="objeFleetDriverModel"></param>
        /// <returns></returns>
        public eFleetDriverModel SaveEfleetDriver(eFleetDriverModel objeFleetDriverModel)
        {
            try
            {
                var objLocationMaster         = new LocationMaster();
                var objeFleetDriver           = new eFleetDriver();
                var objeFleetDriverRepository = new eFleetDriverRepository();
                var objeTracLoginModel        = new eTracLoginModel();

                if (objeFleetDriverModel.DriverID == 0)
                {
                    AutoMapper.Mapper.CreateMap <eFleetDriverModel, eFleetDriver>();
                    var objfleetDriverMapper = AutoMapper.Mapper.Map(objeFleetDriverModel, objeFleetDriver);
                    objeFleetDriverRepository.Add(objfleetDriverMapper);
                    //objeFleetDriver.QRCCodeID = objeFleetDriverModel.QRCCodeID + "EFD" + (objeFleetDriver.DriverID + 100).ToString();
                    objeFleetDriverRepository.SaveChanges();
                    objeFleetDriverModel.Result = Result.Completed;

                    if (objeFleetDriverModel.Result == Result.Completed)
                    {
                        #region Save DAR
                        DARModel objDAR = new DARModel();
                        objDAR.ActivityDetails = DarMessage.RegisterNeweFleetDriver(objeFleetDriverModel.LocationName);
                        objDAR.LocationId      = objeFleetDriverModel.LocationID;
                        objDAR.UserId          = objeFleetDriverModel.UserID;
                        objDAR.CreatedBy       = objeFleetDriverModel.UserID;
                        objDAR.CreatedOn       = DateTime.UtcNow;
                        objDAR.TaskType        = (long)TaskTypeCategory.eFleetDriverSubmission;
                        Result result = _ICommonMethod.SaveDAR(objDAR);
                        #endregion Save DAR
                    }
                }
                //edit Data
                else
                {
                    var DriverData = objeFleetDriverRepository.GetAll(v => v.IsDeleted == false && v.DriverID == objeFleetDriverModel.DriverID).FirstOrDefault();
                    if (objeFleetDriverModel.DriverImageFile != null)
                    {
                    }
                    else
                    {
                        objeFleetDriverModel.DriverImage = DriverData.DriverImage;
                    }
                    //== null ? "" : HostingPrefix + ProfilePicPath.Replace("~", "") + DriverData.DriverImage;
                    AutoMapper.Mapper.CreateMap <eFleetDriverModel, eFleetDriver>();
                    var objfleetDriverMapper = AutoMapper.Mapper.Map(objeFleetDriverModel, DriverData);
                    objeFleetDriverRepository.SaveChanges();
                    objeFleetDriverModel.Result = Result.UpdatedSuccessfully;
                    if (objeFleetDriverModel.Result == Result.UpdatedSuccessfully)
                    {
                        #region Save DAR
                        DARModel objDAR = new DARModel();
                        objDAR.ActivityDetails = DarMessage.UpdateeFleetDriver(objeFleetDriverModel.LocationName);
                        objDAR.LocationId      = objeFleetDriverModel.LocationID;
                        objDAR.UserId          = objeFleetDriverModel.UserID;
                        objDAR.ModifiedBy      = objeFleetDriverModel.UserID;
                        objDAR.ModifiedOn      = DateTime.UtcNow;
                        objDAR.TaskType        = (long)TaskTypeCategory.UpdateeFleetDriver;
                        Result result = _ICommonMethod.SaveDAR(objDAR);
                        #endregion Save DAR
                    }
                }
                return(objeFleetDriverModel);
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public eFleetDriverModel SaveEfleetDriver(eFleetDriverModel objeFleetDriverModel)", "Exception While saving Driver request.", objeFleetDriverModel);
                throw;
            }
        }