public DocumentFileResponse Delete(Guid identifier)
        {
            DocumentFileResponse response = new DocumentFileResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();

                SqliteCommand insertCommand = new SqliteCommand();
                insertCommand.Connection = db;

                //Use parameterized query to prevent SQL injection attacks
                insertCommand.CommandText = "DELETE FROM DocumentFiles WHERE Identifier = @Identifier";
                insertCommand.Parameters.AddWithValue("@Identifier", identifier);

                try
                {
                    insertCommand.ExecuteNonQuery();
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    return(response);
                }
                db.Close();

                response.Success = true;
                return(response);
            }
        }
        public DocumentFileResponse Create(DocumentFileViewModel DocumentFile)
        {
            DocumentFileResponse response = new DocumentFileResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                SqliteCommand insertCommand = db.CreateCommand();
                insertCommand.CommandText = SqlCommandInsertPart;

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, DocumentFile);
                    insertCommand.ExecuteNonQuery();
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    return(response);
                }
                db.Close();

                response.Success = true;
                return(response);
            }
        }
        public DocumentFileResponse Create(DocumentFileViewModel viewModel)
        {
            DocumentFileResponse response = new DocumentFileResponse();

            try
            {
                response.DocumentFile = unitOfWork.GetDocumentFileRepository().Create(viewModel.ConvertToDocumentFile())
                                        ?.ConvertToDocumentFileViewModel();
                response.Success = true;
            } catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
        public DocumentFileResponse Clear(int companyId)
        {
            DocumentFileResponse response = new DocumentFileResponse();

            try
            {
                unitOfWork.GetDocumentFileRepository().Clear(companyId);
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
        public DocumentFileResponse Delete(DocumentFileViewModel toDelete)
        {
            DocumentFileResponse response = new DocumentFileResponse();

            try
            {
                response = WpfApiHandler.SendToApi <DocumentFileViewModel, DocumentFileResponse>(toDelete, "Delete");
            }
            catch (Exception ex)
            {
                response.DocumentFile = new DocumentFileViewModel();
                response.Success      = false;
                response.Message      = ex.Message;
            }

            return(response);
        }
        public DocumentFileResponse Delete(DocumentFileViewModel toDelete)
        {
            DocumentFileResponse response = new DocumentFileResponse();

            try
            {
                response.DocumentFile = unitOfWork.GetDocumentFileRepository().Delete(toDelete?.Id ?? 0)
                                        ?.ConvertToDocumentFileViewModel();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
Esempio n. 7
0
        public JsonResult Delete([FromBody] DocumentFileViewModel c)
        {
            DocumentFileResponse response = new DocumentFileResponse();

            try
            {
                response = this.documentFileService.Delete(c);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                Console.WriteLine(ex.Message);
            }

            return(Json(response, new Newtonsoft.Json.JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented
            }));
        }
Esempio n. 8
0
        public JsonResult Clear(int CompanyId)
        {
            DocumentFileResponse response = new DocumentFileResponse();

            try
            {
                response = documentFileService.Clear(CompanyId);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                Console.WriteLine(ex.Message);
            }

            return(Json(response, new Newtonsoft.Json.JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented
            }));
        }
        public DocumentFileResponse Clear(int companyId)
        {
            DocumentFileResponse response = new DocumentFileResponse();

            try
            {
                response = WpfApiHandler.GetFromApi <DocumentFileViewModel, DocumentFileResponse>("Clear", new Dictionary <string, string>()
                {
                    { "CompanyId", companyId.ToString() }
                });
            }
            catch (Exception ex)
            {
                response.DocumentFile = new DocumentFileViewModel();
                response.Success      = false;
                response.Message      = ex.Message;
            }

            return(response);
        }