Exemple #1
0
        /// <summary>
        /// Created By Ashwajit Bansod
        /// for Deleting the Driver and set IsDeleted Field to 1
        /// </summary>
        /// <param name="driverId"></param>
        /// <param name="loggedInUserId"></param>
        /// <returns></returns>
        public Result DeleteeFleetDriver(long driverId, long loggedInUserId, string location)
        {
            var objDAR = new DARModel();

            try
            {
                Result result;
                if (driverId > 0)
                {
                    eFleetDriverRepository objeFleetDriverRepository = new eFleetDriverRepository();
                    var data = objeFleetDriverRepository.GetSingleOrDefault(v => v.DriverID == driverId && v.IsDeleted == false);
                    if (data != null)
                    {
                        data.IsDeleted   = true;
                        data.DeletedBy   = Convert.ToInt32(loggedInUserId);
                        data.DeletedDate = DateTime.UtcNow;
                        objeFleetDriverRepository.Update(data);

                        objeFleetDriverRepository.SaveChanges();
                        //var objDAR = new DARModel();
                        objDAR.ActivityDetails = DarMessage.DeleteFleetDriver(location);
                        objDAR.TaskType        = (long)TaskTypeCategory.DeleteeFleetDriver;

                        #region Save DAR
                        objDAR.LocationId = data.LocationID.Value;
                        objDAR.UserId     = loggedInUserId;
                        objDAR.DeletedBy  = data.DeletedBy;
                        objDAR.DeletedOn  = DateTime.UtcNow;
                        result            = _ICommonMethod.SaveDAR(objDAR);
                        #endregion Save DAR

                        return(Result.Delete);
                    }
                }
                else
                {
                    return(Result.DoesNotExist);
                }
                return(Result.Delete);
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, " public Result DeleteeFleetDriver(long driverId, long loggedInUserId)", "Exception While Deleting Driver.", null);
                throw;
            }
        }
Exemple #2
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;
            }
        }