public ActionResult saveDocumentTypes(List <string> toBeDeleted, List <string> toBeAdded)
 {
     try
     {
         CMSEntities m_context = new CMSEntities();
         m_context.Configuration.ProxyCreationEnabled = false;
         List <string> failedToDelete = new List <string>();
         if (toBeAdded != null)
         {
             foreach (var item in toBeAdded)
             {
                 var query = m_context.DOCUMENT_TYPE.Where(a => a.NAME_AR == item);
                 if (!query.Select(q => q.NAME_AR).Contains(item))
                 {
                     m_context.DOCUMENT_TYPE.Add(new DOCUMENT_TYPE {
                         NAME_AR = item
                     });
                 }
             }
             m_context.SaveChanges();
         }
         if (toBeDeleted != null)
         {
             foreach (var item in toBeDeleted)
             {
                 try
                 {
                     DOCUMENT_TYPE s = (DOCUMENT_TYPE)m_context.DOCUMENT_TYPE.Where(a => a.NAME_AR == item).First();
                     m_context.DOCUMENT_TYPE.Remove(s);
                 }
                 catch (Exception ex)
                 {
                     failedToDelete.Add(item);
                 }
             }
         }
         m_context.SaveChanges();
         var current = (from row in m_context.DOCUMENT_TYPE select row.NAME_AR).ToList();
         return(Json(new object[] { failedToDelete, current }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #2
0
        public static DOCUMENT ToDocumentMockup(this Request.REQ_DOCUMENT request, string code, DOCUMENT_TYPE docType, TRANS_TYPE transType)
        {
            PERIOD period = new PERIOD();

            period.BEGIN = string.IsNullOrEmpty(request.FILTER.BEGIN) ? $"{DateTime.Today:yyyy-MM-dd}" : request.FILTER.BEGIN;
            period.END   = string.IsNullOrEmpty(request.FILTER.END) ? $"{new DateTime(9999, 12, 31):yyyy-MM-dd}" : request.FILTER.END;

            DOCUMENT oDocument = DOCUMENT.CreateInstance();

            oDocument.CODE       = $"Document {code}";
            oDocument.DOC_TYPE   = docType;
            oDocument.TRANS_TYPE = transType;
            oDocument.PLAN_BEGIN = period.BEGIN;
            oDocument.PLAN_END   = period.END;
            oDocument.REQUESTOR  = request.ToEmployeeMockup(true);
            oDocument.STATUS     = "Waiting";
            oDocument.TRANS_DATE = oDocument.PLAN_BEGIN;
            return(oDocument);
        }
Exemple #3
0
 public UndoEvent(string actionName, DOCUMENT_TYPE obj)
 {
     this.obj        = (DOCUMENT_TYPE)obj.Clone();
     this.actionName = actionName;
 }