Ejemplo n.º 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;
            }
        }