Ejemplo n.º 1
0
 public override bool DeleteData(int id, out Library.DTO.Notification notification)
 {
     notification = new Library.DTO.Notification()
     {
         Type = Library.DTO.NotificationType.Success
     };
     try
     {
         using (DocumentMonitoringMngEntities context = CreateContext())
         {
             DocumentMonitoring dbItem = context.DocumentMonitoring.FirstOrDefault(o => o.DocumentMonitoringID == id);
             if (dbItem == null)
             {
                 notification.Message = "document not found!";
                 return(false);
             }
             else
             {
                 context.DocumentMonitoring.Remove(dbItem);
                 context.SaveChanges();
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         notification.Type    = Library.DTO.NotificationType.Error;
         notification.Message = ex.Message;
         if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
         {
             notification.DetailMessage.Add(ex.InnerException.Message);
         }
         return(false);
     }
 }
Ejemplo n.º 2
0
        public override bool UpdateData(int id, ref DTO.DocumentMonitoringMng.DocumentMonitoring dtoItem, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DocumentMonitoringMngEntities context = CreateContext())
                {
                    DocumentMonitoring dbItem = null;
                    if (id == 0)
                    {
                        dbItem = new DocumentMonitoring();
                        context.DocumentMonitoring.Add(dbItem);
                    }
                    else
                    {
                        dbItem = context.DocumentMonitoring.FirstOrDefault(o => o.DocumentMonitoringID == id);
                    }

                    if (dbItem == null)
                    {
                        notification.Message = "invoice not found!";
                        return(false);
                    }
                    else
                    {
                        // check concurrency
                        if (dbItem.ConcurrencyFlag != null && !dbItem.ConcurrencyFlag.SequenceEqual(Convert.FromBase64String(dtoItem.ConcurrencyFlag_String)))
                        {
                            throw new Exception(DALBase.Helper.TEXT_CONCURRENCY_CONFLICT);
                        }

                        //convert dto to db
                        converter.DTO2DB_DocumentMonitoring(dtoItem, ref dbItem);
                        context.SaveChanges();

                        //Get return data
                        dtoItem = GetData(dbItem.DocumentMonitoringID, out notification);
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool QuickUpdateData(int UserID, ref List <DTO.DocumentMonitoringMng.DocumentMonitoringSearchUpdate> dtoItem, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DocumentMonitoringMngEntities context = CreateContext())
                {
                    foreach (DTO.DocumentMonitoringMng.DocumentMonitoringSearchUpdate item in dtoItem)
                    {
                        DocumentMonitoring dbItem = null;
                        dbItem = context.DocumentMonitoring.FirstOrDefault(o => o.DocumentMonitoringID == item.DocumentMonitoringID);


                        if (dbItem == null)
                        {
                            notification.Message = "Data not found!";
                            return(false);
                        }
                        else
                        {
                            if (item.IsEdit == 1)
                            {
                                converter.DTO2DB_QuickDocumentMonitoring(item, ref dbItem);
                                dbItem.UpdatedBy   = UserID;
                                dbItem.UpdatedDate = DateTime.Now;
                            }
                            context.SaveChanges();
                        }
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
                return(false);
            }
        }
Ejemplo n.º 4
0
 public void DTO2DB_QuickDocumentMonitoring(DTO.DocumentMonitoringMng.DocumentMonitoringSearchUpdate dtoItem, ref DocumentMonitoring dbItem)
 {
     AutoMapper.Mapper.Map <DTO.DocumentMonitoringMng.DocumentMonitoringSearchUpdate, DocumentMonitoring>(dtoItem, dbItem);
     if (!string.IsNullOrEmpty(dtoItem.SendToEUDate))
     {
         dbItem.SendToEUDate = dtoItem.SendToEUDate.ConvertStringToDateTime();
     }
 }
Ejemplo n.º 5
0
 public void DTO2DB_DocumentMonitoring(DTO.DocumentMonitoringMng.DocumentMonitoring dtoItem, ref DocumentMonitoring dbItem)
 {
     AutoMapper.Mapper.Map <DTO.DocumentMonitoringMng.DocumentMonitoring, DocumentMonitoring>(dtoItem, dbItem);
     if (dtoItem.DocumentMonitoringID > 0)
     {
         dbItem.UpdatedDate = DateTime.Now;
         dbItem.UpdatedBy   = dtoItem.UpdatedBy;
     }
     else
     {
         dbItem.CreatedDate = DateTime.Now;
         dbItem.CreatedBy   = dtoItem.UpdatedBy;
     }
     dbItem.VNReceivedDate = dtoItem.VNReceivedDate.ConvertStringToDateTime();
     dbItem.SendToEUDate   = dtoItem.SendToEUDate.ConvertStringToDateTime();
 }