Exemplo n.º 1
0
 public bool ConfirmDateContainerDelivery(int id, string dateContainerDelivery, int confirmedBy, out Library.DTO.Notification notification)
 {
     notification = new Library.DTO.Notification()
     {
         Type = Library.DTO.NotificationType.Success, Message = "Date container delivery have been confirmed success"
     };
     try
     {
         using (DocumentClientMngEntities context = CreateContext())
         {
             DocumentClient dbItem = context.DocumentClient.Where(o => o.DocumentClientID == id).FirstOrDefault();
             dbItem.DateContainerDelivery              = dateContainerDelivery.ConvertStringToDateTime();
             dbItem.IsConfirmedDateContainerDelivery   = true;
             dbItem.ConfirmedDateContainerDeliveryBy   = confirmedBy;
             dbItem.ConfirmedDateContainerDeliveryDate = 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);
     }
 }
Exemplo n.º 2
0
 public bool Add_PaymentStatus(string PaymentStatusNM, out int PaymentStatusID, out Library.DTO.Notification notification)
 {
     notification = new Library.DTO.Notification()
     {
         Type = Library.DTO.NotificationType.Success
     };
     PaymentStatusID = -1;
     try
     {
         using (DocumentClientMngEntities context = CreateContext())
         {
             PaymentStatus dbItem = null;
             if (!string.IsNullOrEmpty(PaymentStatusNM))
             {
                 dbItem = new PaymentStatus();
                 dbItem.PaymentStatusNM = PaymentStatusNM;
                 context.PaymentStatus.Add(dbItem);
                 context.SaveChanges();
                 PaymentStatusID = dbItem.PaymentStatusID;
                 return(true);
             }
         }
         return(false);
     }
     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);
     }
 }
Exemplo n.º 3
0
 public bool Add_TypeOfDelivery(string TypeOfDeliveryNM, out int TypeOfDeliveryID, out Library.DTO.Notification notification)
 {
     notification = new Library.DTO.Notification()
     {
         Type = Library.DTO.NotificationType.Success
     };
     TypeOfDeliveryID = -1;
     try
     {
         using (DocumentClientMngEntities context = CreateContext())
         {
             TypeOfDelivery dbItem = null;
             if (!string.IsNullOrEmpty(TypeOfDeliveryNM))
             {
                 dbItem = new TypeOfDelivery();
                 dbItem.TypeOfDeliveryNM = TypeOfDeliveryNM;
                 context.TypeOfDelivery.Add(dbItem);
                 context.SaveChanges();
                 TypeOfDeliveryID = dbItem.TypeOfDeliveryID;
                 return(true);
             }
         }
         return(false);
     }
     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);
     }
 }
Exemplo n.º 4
0
        public override bool UpdateData(int id, ref DTO.DocumentClientMng.DocumentClient dtoItem, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DocumentClientMngEntities context = CreateContext())
                {
                    DocumentClient dbItem = null;
                    if (id == 0)
                    {
                        dbItem = new DocumentClient();
                        context.DocumentClient.Add(dbItem);
                    }
                    else
                    {
                        dbItem = context.DocumentClient.FirstOrDefault(o => o.DocumentClientID == id);
                    }

                    if (dbItem == null)
                    {
                        notification.Message = "Data not found!";
                        return(false);
                    }
                    else
                    {
                        converter.DTO2DB_DocumentClient(dtoItem, ref dbItem);
                        if (id == 0)
                        {
                            dbItem.CreatedBy   = dtoItem.UpdatedBy;
                            dbItem.CreatedDate = DateTime.Now;
                        }
                        else
                        {
                            dbItem.UpdatedBy   = dtoItem.UpdatedBy;
                            dbItem.UpdatedDate = DateTime.Now;
                        }
                        context.SaveChanges();

                        dtoItem = GetData(dbItem.DocumentClientID, 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);
            }
        }
Exemplo n.º 5
0
        public bool QuickUpdateData(int UserID, ref List <DTO.DocumentClientMng.DocumentClientSearchUpdate> dtoItem, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DocumentClientMngEntities context = CreateContext())
                {
                    foreach (DTO.DocumentClientMng.DocumentClientSearchUpdate item in dtoItem)
                    {
                        DocumentClient dbItem = null;
                        dbItem = context.DocumentClient.FirstOrDefault(o => o.DocumentClientID == item.DocumentClientID);


                        if (dbItem == null)
                        {
                            notification.Message = "Data not found!";
                            return(false);
                        }
                        else
                        {
                            if (item.IsEdit == 1)
                            {
                                converter.DTO2DB_QuickDocumentClient(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);
            }
        }
Exemplo n.º 6
0
        public override bool DeleteData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DocumentClientMngEntities context = CreateContext())
                {
                    DocumentClient dbItem = context.DocumentClient.FirstOrDefault(o => o.DocumentClientID == id);
                    if (dbItem == null)
                    {
                        notification.Message = "Material not found!";
                        return(false);
                    }
                    else
                    {
                        context.DocumentClient.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);
            }
        }