Beispiel #1
0
 public ReturnValues SaveUserFile(AppFile obj)
 {
     using (TransactionScope trans = new TransactionScope())
     {
         try
         {
             ReturnValues ret = null;
             using (RepsistoryEF <AppFile> _o = new RepsistoryEF <AppFile>())
             {
                 obj.IsDownloaded = false;
                 obj.Timestamp    = DateTime.Now;
                 var result = _o.Save(obj);
                 if (result != null)
                 {
                     ret = new ReturnValues
                     {
                         Success = "File has been saved successfully.",
                         Source  = "0",
                     };
                 }
                 else
                 {
                     ret = new ReturnValues
                     {
                         Success = "Failed to save",
                         Source  = "0",
                     };
                 }
                 trans.Complete();
             }
             return(ret);
         }
         catch (Exception ex)
         {
             trans.Dispose();
             ReturnValues objex = new ReturnValues
             {
                 Failure = ex.Message,
             };
             throw ex;
         }
         finally
         {
             trans.Dispose();
         }
     }
 }
Beispiel #2
0
 public ReturnValues AddComment(DiscussionComment obj)
 {
     using (TransactionScope trans = new TransactionScope())
     {
         try
         {
             ReturnValues ret = null;
             using (RepsistoryEF <DiscussionComment> _o = new RepsistoryEF <DiscussionComment>())
             {
                 var result = _o.Save(obj);
                 if (result != null)
                 {
                     ret = new ReturnValues
                     {
                         Success = "Comment posted successfully.",
                         Source  = "0",
                     };
                 }
                 else
                 {
                     ret = new ReturnValues
                     {
                         Success = "Failed to save",
                         Source  = "0",
                     };
                 }
                 trans.Complete();
             }
             return(ret);
         }
         catch (Exception ex)
         {
             trans.Dispose();
             ReturnValues objex = new ReturnValues
             {
                 Failure = ex.Message,
             };
             throw ex;
         }
         finally
         {
             trans.Dispose();
         }
     }
 }