示例#1
0
        //public PhysicalPersonLicenceResponse DeleteAll()
        //{
        //    PhysicalPersonLicenceResponse response = new PhysicalPersonLicenceResponse();

        //    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 PhysicalPersonLicences";
        //            try
        //            {
        //                insertCommand.ExecuteReader();
        //            }
        //            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;
        //}

        public PhysicalPersonLicenceResponse SetStatusDeleted(Guid identifier)
        {
            PhysicalPersonLicenceResponse response = new PhysicalPersonLicenceResponse();

            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 = "UPDATE PhysicalPersonLicences SET ItemStatus = @ItemStatus WHERE Identifier = @Identifier";
                insertCommand.Parameters.AddWithValue("@ItemStatus", ItemStatus.Deleted);
                insertCommand.Parameters.AddWithValue("@Identifier", identifier);

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

                response.Success = true;
                return(response);
            }
        }
示例#2
0
        public PhysicalPersonLicenceResponse Create(PhysicalPersonLicenceViewModel PhysicalPersonItem)
        {
            PhysicalPersonLicenceResponse response = new PhysicalPersonLicenceResponse();

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

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, PhysicalPersonItem);
                    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 PhysicalPersonLicenceResponse Create(PhysicalPersonLicenceViewModel PhysicalPersonItemViewModel)
        {
            PhysicalPersonLicenceResponse response = new PhysicalPersonLicenceResponse();

            try
            {
                response = WpfApiHandler.SendToApi <PhysicalPersonLicenceViewModel, PhysicalPersonLicenceResponse>(PhysicalPersonItemViewModel, "Create");
            }
            catch (Exception ex)
            {
                response.PhysicalPersonLicence = new PhysicalPersonLicenceViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
        public PhysicalPersonLicenceResponse Create(PhysicalPersonLicenceViewModel PhysicalPersonItemViewModel)
        {
            PhysicalPersonLicenceResponse response = new PhysicalPersonLicenceResponse();

            try
            {
                var addedPhysicalPersonItem = unitOfWork.GetPhysicalPersonLicenceRepository().Create(PhysicalPersonItemViewModel.ConvertToPhysicalPersonLicence());
                unitOfWork.Save();
                response.PhysicalPersonLicence = addedPhysicalPersonItem.ConvertToPhysicalPersonLicenceViewModel();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.PhysicalPersonLicence = new PhysicalPersonLicenceViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
        public JsonResult Create([FromBody] PhysicalPersonLicenceViewModel c)
        {
            PhysicalPersonLicenceResponse response = new PhysicalPersonLicenceResponse();

            try
            {
                response = this.PhysicalPersonItemService.Create(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
            }));
        }
示例#6
0
        public PhysicalPersonLicenceResponse GetPhysicalPersonLicence(Guid identifier)
        {
            PhysicalPersonLicenceResponse  response           = new PhysicalPersonLicenceResponse();
            PhysicalPersonLicenceViewModel PhysicalPersonItem = new PhysicalPersonLicenceViewModel();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM  PhysicalPersonLicences " +
                        "WHERE Identifier = @Identifier;", db);
                    selectCommand.Parameters.AddWithValue("@Identifier", identifier);

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        PhysicalPersonLicenceViewModel dbEntry = Read(query);
                        PhysicalPersonItem = dbEntry;
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage        = error.Message;
                    response.Success               = false;
                    response.Message               = error.Message;
                    response.PhysicalPersonLicence = new PhysicalPersonLicenceViewModel();
                    return(response);
                }
                db.Close();
            }
            response.Success = true;
            response.PhysicalPersonLicence = PhysicalPersonItem;
            return(response);
        }