Beispiel #1
0
        public long UpdateNotificationHistory(NotificationHistoryObject notificationHistory)
        {
            try
            {
                if (notificationHistory == null)
                {
                    return(-2);
                }

                var notificationHistoryEntity = ModelMapper.Map <NotificationHistoryObject, NotificationHistory>(notificationHistory);
                if (notificationHistoryEntity == null || notificationHistoryEntity.Id < 1)
                {
                    return(-2);
                }

                using (var db = new ImportPermitEntities())
                {
                    db.NotificationHistories.Attach(notificationHistoryEntity);
                    db.Entry(notificationHistoryEntity).State = EntityState.Modified;
                    db.SaveChanges();
                    return(notificationHistory.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Beispiel #2
0
        public long AddNotificationHistory(NotificationHistoryObject notificationHistory)
        {
            try
            {
                if (notificationHistory == null)
                {
                    return(-2);
                }

                var notificationHistoryEntity = ModelMapper.Map <NotificationHistoryObject, NotificationHistory>(notificationHistory);
                if (notificationHistoryEntity == null || string.IsNullOrEmpty(notificationHistoryEntity.Notification.Invoice.ReferenceCode))
                {
                    return(-2);
                }
                using (var db = new ImportPermitEntities())
                {
                    var returnStatus = db.NotificationHistories.Add(notificationHistoryEntity);
                    db.SaveChanges();
                    return(returnStatus.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Beispiel #3
0
 public long UpdateNotificationHistory(NotificationHistoryObject notificationHistory)
 {
     try
     {
         return(_notificationHistoryManager.UpdateNotificationHistory(notificationHistory));
     }
     catch (Exception ex)
     {
         ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
        public List <NotificationHistoryObject> GetPreviousNotificationJobsHistorys(int?itemsPerPage, int?pageNumber, out int countG, string userId)
        {
            try
            {
                if ((itemsPerPage != null && itemsPerPage > 0) && (pageNumber != null && pageNumber >= 0))
                {
                    var tpageNumber = (int)pageNumber;
                    var tsize       = (int)itemsPerPage;

                    using (var db = new ImportPermitEntities())
                    {
                        //get the id of the userprofile table
                        var registeredGuys = db.AspNetUsers.Find(userId);
                        var profileId      = registeredGuys.UserProfile.Id;

                        //get the employee id on employee desk table
                        var employeeDesk = db.EmployeeDesks.Where(e => e.EmployeeId == profileId).ToList();

                        if (employeeDesk.Any())
                        {
                            var employeeId = employeeDesk[0].Id;

                            var processTrackings =
                                db.NotificationHistories.Where(m => m.EmployeeId.Equals(employeeId)).OrderByDescending(m => m.Id)
                                .Skip(tpageNumber).Take(tsize)
                                .Include("Notification")
                                .ToList();
                            if (processTrackings.Any())
                            {
                                var newList = new List <NotificationHistoryObject>();
                                //processTrackings.ForEach(app =>
                                //{
                                //    var processTrackingObject = ModelMapper.Map<NotificationHistory, NotificationHistoryObject>(app);
                                //    if (processTrackingObject != null && processTrackingObject.Id > 0)
                                //    {
                                //        processTrackingObject.CompanyName = app.Notification.Importer.Name;
                                //        processTrackingObject.ReferenceCode = app.Notification.Invoice.ReferenceCode;
                                //        processTrackingObject.AssignedTimeStr = app.AssignedTime.ToString();

                                //        processTrackingObject.ActualDeliveryDateTimeStr = app.FinishedTime.ToString();
                                //        newList.Add(processTrackingObject);
                                //    }
                                //});

                                foreach (var item in processTrackings)
                                {
                                    var obj = new NotificationHistoryObject();
                                    obj.Id                        = item.Id;
                                    obj.CompanyName               = item.Notification.Importer.Name;
                                    obj.ReferenceCode             = item.Notification.Invoice.RRR;
                                    obj.AssignedTimeStr           = item.AssignedTime.ToString();
                                    obj.ActualDeliveryDateTimeStr = item.FinishedTime.ToString();
                                    obj.Remarks                   = item.Remarks;
                                    newList.Add(obj);
                                }
                                countG = db.NotificationHistories.Count();
                                return(newList);
                            }
                        }
                    }
                }
                countG = 0;
                return(new List <NotificationHistoryObject>());
            }
            catch (Exception ex)
            {
                countG = 0;
                return(new List <NotificationHistoryObject>());
            }
        }