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

            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 PhysicalPersonAttachments 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 PhysicalPersonAttachmentResponse Delete(Guid identifier)
        {
            PhysicalPersonAttachmentResponse response = new PhysicalPersonAttachmentResponse();

            try
            {
                response = WpfApiHandler.SendToApi <Guid, PhysicalPersonAttachmentViewModel, PhysicalPersonAttachmentResponse>(identifier, "Delete");
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
        public PhysicalPersonAttachmentResponse Create(PhysicalPersonAttachmentViewModel PhysicalPersonAttachment)
        {
            PhysicalPersonAttachmentResponse response = new PhysicalPersonAttachmentResponse();

            try
            {
                response = WpfApiHandler.SendToApi <PhysicalPersonAttachmentViewModel, PhysicalPersonAttachmentResponse>(PhysicalPersonAttachment, "Create");
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
Example #4
0
        public PhysicalPersonAttachmentResponse Create(PhysicalPersonAttachmentViewModel PhysicalPersonAttachment)
        {
            PhysicalPersonAttachmentResponse response = new PhysicalPersonAttachmentResponse();

            try
            {
                response.PhysicalPersonAttachment = unitOfWork.GetPhysicalPersonAttachmentRepository().Create(PhysicalPersonAttachment.ConvertToPhysicalPersonAttachment())
                                                    .ConvertToPhysicalPersonAttachmentViewModel();

                unitOfWork.Save();

                response.Success = true;
            } catch (Exception ex)
            {
                response         = new PhysicalPersonAttachmentResponse();
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
        public PhysicalPersonAttachmentResponse DeleteAll()
        {
            PhysicalPersonAttachmentResponse response = new PhysicalPersonAttachmentResponse();

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

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

                    //Use parameterized query to prevent SQL injection attacks
                    insertCommand.CommandText = "DELETE FROM PhysicalPersonAttachments ";
                    try
                    {
                        insertCommand.ExecuteNonQuery();
                    }
                    catch (SqliteException error)
                    {
                        response.Success = false;
                        response.Message = error.Message;

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

            response.Success = true;
            return(response);
        }